A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by FSA » Tue Nov 13, 2012 4:42 pm
Error is happening here. Before that code matrix is ok. After it some strange values in matrix.
- Code: Select all
// integrate linear velocity
dFloat normalizedTimeLeft = 1.0f;
dFloat step = timestep * dSqrt (veloc % veloc) ;
dFloat descreteTimeStep = timestep * (1.0f / D_DESCRETE_MOTION_STEPS);
int prevContactCount = 0;
CustomControllerFilterCastFilter castFilterData (body);
NewtonWorldConvexCastReturnInfo prevInfo[PLAYER_CONTROLLER_MAX_CONTACTS];
for (int i = 0; (i < D_PLAYER_MAX_INTERGRATION_STEPS) && (normalizedTimeLeft > 1.0e-5f); i ++ ) {
if ((veloc % veloc) < 1.0e-5f) {
break;
}
dFloat timetoImpact;
NewtonWorldConvexCastReturnInfo info[PLAYER_CONTROLLER_MAX_CONTACTS];
dVector destPosit (matrix.m_posit + veloc.Scale (timestep));
int contactCount = NewtonWorldConvexCast (world, &matrix[0][0], &destPosit[0], m_collisionShape, &timetoImpact, &castFilterData, CustomControllerFilterCastFilter::ConvexStaticCastPrefilter, info, sizeof (info) / sizeof (info[0]), threadIndex);
if (contactCount) {
contactCount = manager->ProcessContacts (this, info, contactCount);
}
if (contactCount) {
if (timetoImpact > 0.0f) {
matrix.m_posit += veloc.Scale (timetoImpact * timestep);
}
normalizedTimeLeft -= timetoImpact;
dFloat speed[PLAYER_CONTROLLER_MAX_CONTACTS * 2];
dFloat bounceSpeed[PLAYER_CONTROLLER_MAX_CONTACTS * 2];
dVector bounceNormal[PLAYER_CONTROLLER_MAX_CONTACTS * 2];
int count = 0;
const dFloat restitution = 0.0f;
for (int i = 0; i < contactCount; i ++) {
speed[count] = 0.0f;
bounceNormal[count] = info[i].m_normal;
dFloat reboundVelocMag = -(veloc % bounceNormal[count]) * (1.0f + restitution);
bounceSpeed[count] = (reboundVelocMag > 0.0f) ? reboundVelocMag : 0.0f;
count ++;
}
for (int i = 0; i < prevContactCount; i ++) {
speed[count] = 0.0f;
bounceNormal[count] = prevInfo[i].m_normal;
dFloat reboundVeloc = (veloc % bounceNormal[count]) * (1.0f + restitution);
bounceSpeed[count] = (reboundVeloc > 0.0f) ? reboundVeloc : 0.0f;
count ++;
}
dFloat residual = 10.0f;
dVector auxBounceVeloc (0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; (i < D_PLAYER_MAX_SOLVER_ITERATIONS) && (residual > 1.0e-3f); i ++) {
residual = 0.0f;
for (int k = 0; k < count; k ++) {
dFloat v = bounceSpeed[k] - bounceNormal[k] % auxBounceVeloc;
dFloat x = speed[k] + v;
if (x < 0.0f) {
v = 0.0f;
x = 0.0f;
}
if (dAbs (v) > residual) {
residual = dAbs (v);
}
auxBounceVeloc += bounceNormal[k].Scale (x - speed[k]);
speed[k] = x;
}
}
dVector velocStep (0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; i < count; i ++) {
velocStep += bounceNormal[i].Scale (speed[i]);
}
veloc += velocStep;
dFloat velocMag2 = velocStep % velocStep;
if (velocMag2 < 1.0e-6f) {
dFloat advanceTime = dMin (descreteTimeStep, normalizedTimeLeft * timestep);
matrix.m_posit += veloc.Scale (advanceTime);
normalizedTimeLeft -= advanceTime / timestep;
}
prevContactCount = contactCount;
memcpy (prevInfo, info, prevContactCount * sizeof (NewtonWorldConvexCastReturnInfo));
} else {
matrix.m_posit = destPosit;
matrix.m_posit.m_w = 1.0f;
break;
}
}
I will try to find the position in the code exactlier.
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by FSA » Wed Nov 14, 2012 12:11 pm
So I get the Error. It's a fault by newton I think. In function
- Code: Select all
void CustomPlayerController::PostUpdate(dFloat timestep, int threadIndex)
- Code: Select all
NewtonBodyGetVelocity(body, &veloc[0]);
returns some very high values (e+12). I have test in in first frame the function runs. So logical the next functions will use the velocity like:
- Code: Select all
dVector destPosit (matrix.m_posit + veloc.Scale (timestep));
and then the matrix is very strange.
Debug code:
- Code: Select all
BODY VELOC
5.23636e+012
-1.33333
8.51689e+013
Matrix.m_posit BEFORE USE VELOC
-25
30
0
Matrix.m_posit AFTER USE VELOC
5.23636e+009
29.9987
8.51689e+010
So the error is the velocity.
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Wed Nov 14, 2012 12:48 pm
in function PostUpdate, veloc is adjiste each time a collsion happens, tray to trace teh values of step, to see if somethong is going wrondg there
thishappen here
- Code: Select all
dFloat residual = 10.0f;
dVector auxBounceVeloc (0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; (i < D_PLAYER_MAX_SOLVER_ITERATIONS) && (residual > 1.0e-3f); i ++) {
residual = 0.0f;
for (int k = 0; k < count; k ++) {
dFloat v = bounceSpeed[k] - bounceNormal[k] % auxBounceVeloc;
dFloat x = speed[k] + v;
if (x < 0.0f) {
v = 0.0f;
x = 0.0f;
}
if (dAbs (v) > residual) {
residual = dAbs (v);
}
// HERE trace valee of x and auxBounceVeloc, I think something can go wrong in the solve
auxBounceVeloc += bounceNormal[k].Scale (x - speed[k]);
speed[k] = x;
}
}
dVector velocStep (0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; i < count; i ++) {
velocStep += bounceNormal[i].Scale (speed[i]);
}
veloc += velocStep;
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Wed Nov 14, 2012 12:49 pm
tell something do this happens in teh test that you sent me?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Wed Nov 14, 2012 12:53 pm
Can't find the code. And I also dont really now what you mean
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by FSA » Wed Nov 14, 2012 12:54 pm
No i gave you the debug build. There all works fine.
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Wed Nov 14, 2012 12:58 pm
not give me a release build, It does not help me if teh bug do no happens.
I cna run debug dlls in a release buidl, but I can not run teh opsite will no help if teh bug do n happens.
maybe give two exe, one in debug and one in release.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Wed Nov 14, 2012 1:02 pm
You cant really see the bug. Only the player fly at very high spedd threw th world
Wait i upload it. I give you the source with it.
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Wed Nov 14, 2012 1:15 pm
But how do you make it happens. i soudl eb able to do it too.
I do not need the source I only nee to know how to make happen.
can you just put teh release and debug in the archive? I cna debug like that.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Wed Nov 14, 2012 1:19 pm
I made a SVN-checkout and no nothing compiles anymore
unresolved external symbol ""private: static class dRtti CustomControllerBase::m_rtti" (?m_rtti@CustomControllerBase@@0VdRtti@@A)".
I have that error meanwhile.
To create the bug i do nothing. Right after the start of the program the player fly's away.
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Wed Nov 14, 2012 1:37 pm
did we solved the m_rrti bug, I am totally confused now.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Wed Nov 14, 2012 1:44 pm
Yes but after the checkout, it comes up against. I've make everyrhing like before. Build build.sln buil newton.sln ovverwrite libaries, add JointLibary to my project. Something is really wrong
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Wed Nov 14, 2012 5:40 pm
In source controll look at the history of this file: c:..\packages\dContainers\dRtti.h
you will see that is used to have a base class, and now is a full macro, therefore all instances of m_rtti are pat of the leaf class and should have dll declaration.
edit:
I delete the other post
I do not know what could be wrong has you build the joint library before or were you using the precompile one?
make sure this define JOINTLIBRARY_EXPORTS if set if you build the DLL.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Fri Nov 16, 2012 3:04 pm
So i got it now. After a second svn checkout everthing is fine, and i don't must include the joinlibary into my project.
Here is the link to the relase build:
https://www.dropbox.com/s/hcgjslimgb0km ... _Julio.zipThe Bug happens right after the start. The Position is 1|1|1 but the matrix say 1.#IO 1.#IO 1.#IO
Sometimes it's 1.#IO an sometime some very high values.
Hope you can find the bug
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Fri Nov 16, 2012 3:35 pm
Oh very well, I will get that tonight an debug it.
will also add the pley avility to be push around by moving bodies, which still does not do now.
for example a tank hitting you, it sodu mush you away,
you jumping of the hull of a vehicle, or on top of a platform, the player should inherit the velocity of the floor, and it can even have friction.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 7 guests