Report any bugs here and we'll post fixes
Moderators: Sascha Willems, Thomas
by arkeon » Wed Sep 17, 2014 3:17 pm
http://arkeon.dyndns.org/scol/physic_demo_scale.rarThe exactly same demo, but with collisions created with a 1.0 ratio (no scaling in mesh information) and then scaled with the global scale of the node using the NewtonBodySetCollisionScale.
This is applied on all collisions types.
as you can see the character do not react the same at all and the F5 demo totally fail :/ the camera collision just pass through the ground and fall. the global ground scale is 0.01 but the same problem occur with another collision type with small scale.
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by Julio Jerez » Thu Sep 18, 2014 9:23 am
ok I am looking at this now.
and when I try to debug using the normal newton SDK the first assert happens here
void NewtonUserJointSetRowSpringDamperAcceleration (const NewtonJoint* const joint, dFloat springK, dFloat springD);
are you try to make spring/damper joints
there are also memory leaks on exit, some how you are leaving some objet alive before you call NewtonWorld destroy
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by arkeon » Thu Sep 18, 2014 9:25 am
yes my slider joint have damping / friction and motor
Thanks I will check that
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by Julio Jerez » Thu Sep 18, 2014 10:01 am
Ok the jitter when dragging object pick wit the mouse cursor are because the way you apply the force to them
can you show me that function? Maybe I can give you a better one.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by arkeon » Thu Sep 18, 2014 10:06 am
This part is in scol script ^^ and in fact it works the way I wanted but since this is in a prerender callback the time must not be very precise :/
this look like this
- Code: Select all
let V3DgetDefaultViewport viewstr -> viewportstr in
let SO3ViewportGetWorldPosFromPixelPosition viewportstr.V3D_viewport viewstr.V3D_iMoveX viewstr.V3D_iMoveY obstr.PMOUSE_lastDist -> [pos dir] in
let subVectorF pos SO3ObjectGetPosition obstr.PMOUSE_obj -> trans in
let multiplyVectorF trans vtime -> vel in
(
SO3BodySetVelocity obstr.PMOUSE_body vel;
0;
);
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by arkeon » Thu Sep 18, 2014 10:08 am
in the first demo, do you have the issue when rushing in the doors ?
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by Julio Jerez » Thu Sep 18, 2014 10:32 am
door?
I did no see that.
what language is that? for what I can see you are setting the velocity directly is that what is doing?
can you re white in C or C++ so that I understand it?
write as a function with parameters so that I can write the equivalent and you try that.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by arkeon » Thu Sep 18, 2014 10:40 am
the glass door in the demo when you use F5 key.
this is Scol language.
pseudo code
- Code: Select all
vector3 mousePos; // on camera
vector3 mouseDir; // on camera
vector3 lastBodyPosition;
vector3 translation = mousePos - lastBodyPosition;
vector3 velocity = translation * TimeInverse;
BodyWithContraint.SetVelocity(velocity);
don't loose too much time on this.
ho yes and the joint is not the newton mouse picker, this is a slider joint with damping.
I didn't understood why you where talking of jitter.
the scaling issue and the huge velocity problem when some bodies with joints are hit is much more blocking for me.
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by Julio Jerez » Thu Sep 18, 2014 11:10 am
One thing at a time, please use this function for driving a body to the target location
- Code: Select all
void CalculatePickForceAndTorque (const NewtonBody* const body, const dVector& pointOnBodyInGlobalSpace, const dVector& targetPositionInGlobalScale, dFloat timestep)
{
dVector com;
dMatrix matrix;
dVector omega0;
dVector veloc0;
dVector omega1;
dVector veloc1;
dVector pointVeloc;
const dFloat stiffness = 0.3f;
dFloat invTimeStep = 1.0f / timestep;
NewtonWorld* const world = NewtonBodyGetWorld (body);
NewtonWorldCriticalSectionLock (world, 0);
// calculate the desired impulse
NewtonBodyGetMatrix(body, &matrix[0][0]);
NewtonBodyGetOmega (body, &omega0[0]);
NewtonBodyGetVelocity (body, &veloc0[0]);
NewtonBodyGetPointVelocity (body, &pointOnBodyInGlobalSpace[0], &pointVeloc[0]);
dVector deltaVeloc (targetPositionInGlobalScale - pointOnBodyInGlobalSpace);
deltaVeloc = deltaVeloc.Scale (stiffness * invTimeStep) - pointVeloc;
for (int i = 0; i < 3; i ++) {
dVector veloc (0.0f, 0.0f, 0.0f, 0.0f);
veloc[i] = deltaVeloc[i];
NewtonBodyAddImpulse (body, &veloc[0], &pointOnBodyInGlobalSpace[0]);
}
// damp angular velocity
NewtonBodyGetOmega (body, &omega1[0]);
NewtonBodyGetVelocity (body, &veloc1[0]);
omega1 = omega1.Scale (0.9f);
// restore body velocity and angular velocity
NewtonBodySetOmega (body, &omega0[0]);
NewtonBodySetVelocity(body, &veloc0[0]);
// convert the delta velocity change to a external force and torque
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
dFloat mass;
NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
dVector angularMomentum (Ixx, Iyy, Izz);
angularMomentum = matrix.RotateVector (angularMomentum.CompProduct(matrix.UnrotateVector(omega1 - omega0)));
dVector force ((veloc1 - veloc0).Scale (mass * invTimeStep));
dVector torque (angularMomentum.Scale(invTimeStep));
NewtonBodyAddForce(body, &force[0]);
NewtonBodyAddTorque(body, &torque[0]);
NewtonWorldCriticalSectionUnlock (world);
}
after you get that hook and tune upload the demo again.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by arkeon » Thu Sep 18, 2014 11:15 am
ok thanks I will look at this to add this functionality.
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by Julio Jerez » Thu Sep 18, 2014 12:53 pm
if you sync to givhub, you can see how tha function is used.
I added to the sandbox demos, you can set a break point on function file
void DemoCameraListener::UpdatePickBody(DemoEntityManager* const scene, float timestep)
so that you can see how is called. also make sure you get the function form the code not from what I posted, because that one has a bug that I fixed.
when you get that going please upload the demo and let me know again
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by arkeon » Thu Sep 18, 2014 12:56 pm
Ok thanks I'm on it.
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by arkeon » Thu Sep 18, 2014 2:15 pm
hmm I must done something wrong nothing is moving.
the timeStep is the time in second based on what ? render frame time or physic update step ?
maybe I should use CustomControllerManager to make things like that :/
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by Julio Jerez » Thu Sep 18, 2014 2:24 pm
you do not have to use a controller manager if you do not want.
you can use the Listener directly.
- Code: Select all
void* NewtonWorldGetListenerUserData (const NewtonWorld* const newtonWorld, void* const listener);
void* NewtonWorldGetPreListener (const NewtonWorld* const newtonWorld, const char* const nameId);
void* NewtonWorldAddPreListener (const NewtonWorld* const newtonWorld, const char* const nameId, void* const listenerUserData, NewtonWorldUpdateListenerCallback update, NewtonWorldDestroyListenerCallback destroy);
basically this is a way to plug a call back to the engine that will be called each render frame
after the bodies all force an torque call be for all bodies are called
the callback the a user data and the timeset as parameter.
the on the call back you can implement you pick logic.
you can plug as many listener or Post listeners as you want.
In fact the controller manager are just systems build use those listeners.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by arkeon » Thu Sep 18, 2014 2:37 pm
just to understand why are you using NewtonWorldCriticalSectionlock here ?
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
Return to Bugs and Fixes
Who is online
Users browsing this forum: No registered users and 6 guests