rolling friction dev branch

Software: Other

John Brookes, Moderator
Posted: 13 January 2013 07:29 PM   Total Posts: 732

rolling friction
Its been added in bullet 2.81 which the dev branch uses.
Any chance of adding it?


while Im here…

CModule.readFloat(pointer + 248);
CModule.writeFloat(pointer + 244, v)
etc

Is ther some sort of way of knowing what the number relates to?
Meaning, I get that 224 relates to setting friction but how do you know its 224?

   

Yang Li, Administrator
Posted: 16 January 2013 02:43 AM   Total Posts: 80   [ # 1 ]

I use trace to get the relative pointer address,  for example, the friction is a property of btCollisionObject, So in createCollisionObjectInC function of AwayPhysics.c, I use:

inline_as3(“trace(\“obj pointer is:  \” + %0);\n” : : “r”(&obj;));
inline_as3(“trace(\“obj->m_friction pointer is:  \” + %0);\n” : : “r”(&obj;->m_friction));

then recompile and run, the obj and m_friction pointer address will show in console, so get the relative pointer is m_frictionPointer - objPointer.

 

   

John Brookes, Moderator
Posted: 16 January 2013 11:44 AM   Total Posts: 732   [ # 2 ]

If I use

inline_as3("trace(\"obj pointer is:  \" + %0);\n" : : "r"(&obj;));
inline_as3("trace(\"obj->m_friction pointer is:  \" + %0);\n" : : "r"(&obj;->m_friction)); 

It throws an error on compiling the swc.. expected ‘)’ before ‘;’


So random guess smile

void createCollisionObjectInC() __attribute__((usedannotate("as3sig:public function createCollisionObjectInC(as3_shape:uint):uint"), annotate("as3package:AWPC_Run")));
void createCollisionObjectInC(){
 btCollisionShape
shape;
 
AS3_GetScalarFromVar(shapeas3_shape);
 
 
btCollisionObjectobj = new btCollisionObject();
 
inline_as3("trace(\"obj pointer is:  \" + %0);\n" :: "r"(&obj;));
 
inline_as3("trace(\"obj->m_rollingFriction pointer is:  \" + %0);\n" : : "r"(&obj;->m_rollingFriction));
 
obj->setCollisionShape(shape);
 

 
AS3_Return(obj); 

which compiles but when I run it I get
obj pointer is:  2101228
obj->m_rollingFriction pointer is:  4616760

obj pointer has got to be wrong ?

 

So another random guess…
added
trace(“pointer = ” + pointer);
after
pointer = createCollisionObjectInC(shape.pointer);
in AWPCollisionObject.as

that traces
pointer = 4616528

so
4616760 - 4616528 = 232


Create get/set in AWPCollisionObject.as

public function get rollingFriction() : Number {
 
return CModule.readFloat(pointer 232);
}

public function set rollingFriction(Number) : void {
 CModule
.writeFloat(pointer 232v);

works, now have rollingFriction.
YAY smile

 

   

John Brookes, Moderator
Posted: 16 January 2013 11:48 AM   Total Posts: 732   [ # 3 ]

just testing forum

inline_as3(“trace(\“obj pointer is:  \” + %0);\n” :: “r”(&obj;));

inline_as3("trace(\"obj pointer is:  \" + %0);\n" :: "r"(&obj;)); 


&obj;

&obj

Ok you cant post & obj without it turning in to &obj;
For anyone playing along correct way in txt file.

 

File Attachments
createCollisionObjectInC.txt  (File Size: 1KB - Downloads: 498)
   

dtramer2, Newbie
Posted: 09 July 2013 02:52 AM   Total Posts: 16   [ # 4 ]

prospects of getting this into the downloadable swc file?

 

   

John Brookes, Moderator
Posted: 09 July 2013 09:58 AM   Total Posts: 732   [ # 5 ]

Ive added a pull request to the devs, will be updated when they have time.
Meanwhile..

It doesnt need to be added to the swc. Its already been compiled in from Bullet 2.81.

Open up
AWPCollisionObject.as
its in
awayphysics.collision.dispatch

Add this, about line 323 will do.

public function get rollingFriction() : Number {
 
return CModule.readFloat(pointer 232);
}

public function set rollingFriction(Number) : void {
 CModule
.writeFloat(pointer 232v);

You need to set rollingFriction on whats rolling and the body its rolling on.
eg
ground.rollingFriction = 0.3;
ball.rollingFriction = 0.3;

or just wait for it to be added smile

 

   

John Brookes, Moderator
Posted: 09 July 2013 10:04 AM   Total Posts: 732   [ # 6 ]

rollingFriction now added to dev branch.

 

   

dtramer2, Newbie
Posted: 10 July 2013 02:48 PM   Total Posts: 16   [ # 7 ]

I got the code from the dev branch:

https://github.com/away3d/awayphysics-core-fp11/tree/dev

and its all good now.

Thanks for the quick reply.

 

   

markjosol, Newbie
Posted: 25 October 2013 05:00 AM   Total Posts: 1   [ # 8 ]

compress them in zip format, otherwise the attachment might not work correctly.


______________________________________________
FIFA 14 Coins

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X