A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by KingSnail » Tue May 10, 2011 3:07 pm
I recently added the mass check to the custom character controller so two controllers dont collide together.
No matter what, Newton allways crashes when using the FIndFloor convex cast using this prefilter:
Does this need critical sections or something? because I thought NewtonBodyGetMassMatrix simply reads values.
- Code: Select all
unsigned CustomPlayerController::ConvexAllBodyCastPrefilter(const NewtonBody* body, const NewtonCollision* collision, void* userData)
{
CastFilterData* filterData;
filterData = (CastFilterData*) userData;
for(int i = 0; i < filterData->m_count; ++i)
{
if(filterData->m_filter[i] == body)return 0;
}
if(body)
{
dFloat mass;
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
//NewtonWorldCriticalSectionLock(
NewtonBodyGetMassMatrix(body, &mass, &Ixx, &Iyy, &Izz);
if(mass > 99.0f)return 0;
}
return 1;
}
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by ledahut » Tue May 10, 2011 3:45 pm
Your code seems ok.
I am not sure but when I used convexcast prefilter callback (only one body in my world: the floor), I watched body address (with breakpoint) in the callback and it was always different to my floor body address. And every newton function on this body address crashed.
Like your
NewtonBodyGetMassMatrix(body, &mass, &Ixx, &Iyy, &Izz);
Just check (in you application) what I am saying and report bug (if it is true) to the appropriate sub forum.
ps: I don't have my old project with convexcast anymore
-
ledahut
-
- Posts: 98
- Joined: Mon Jun 21, 2010 8:03 am
- Location: France
by KingSnail » Tue May 10, 2011 4:04 pm
hmm interesting thanks.
I am interested what Julio says to this.
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by Julio Jerez » Tue May 10, 2011 8:52 pm
the first thong I would try is set thread count to one and see if still crash.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by KingSnail » Wed May 11, 2011 1:50 pm
Thread count 8: Crash after 3 minutes
Thread count 1: No crash after an hour
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by Julio Jerez » Wed May 11, 2011 2:52 pm
I do not think there is any wrong in the call back, unless it coping data to the shared memory.
The call back is call from these line in file
d:\Temp\newton-dynamics\packages\dCustomJoints\CustomPlayerController.cpp
contactCount = NewtonWorldConvexCast (m_world, &bodyMatrix[0][0], &destination[0], m_bodySensorShape, &hitParam, &castFilterData, ConvexStaticCastPrefilter, info, sizeof (info) / sizeof (info[0]), threadIndex);
in function CalculateVelocity and PlayerOnFreeFall
can you wrap the call with newton Critical section and see if is work.
That is not teh solution by it will expose if the Bug is in NewtonWorldConvexCast or in the Player controlle joint.
I do not think it is in the NewtonWorldConvexCast because that function the engine used, but if it is we can find it.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by KingSnail » Wed May 11, 2011 3:28 pm
How am I supposed to get NewtonWorld to enter critical section?
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by Julio Jerez » Fri May 13, 2011 5:52 am
these are the functions for critical sections
NewtonWorldCriticalSectionLock (const NewtonWorld* const newtonWorld);
NewtonWorldCriticalSectionUnlock (const NewtonWorld* const newtonWorld);
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by KingSnail » Fri May 13, 2011 10:30 am
Sorry there was a confusion, I meant how do I get the actual NewtonWorld pointer?
Because if i do NewtonBodyGetWorld() it might cause race condition?
I basicly need to access NewtonWorld * from that callback in order to enter critical section.
And all this code is inside CustomCharacterController which I am not familiar with.
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by JernejL » Fri May 13, 2011 11:24 am
newtoncreate makes a pointer to newtonworld, the pointer should be same across any thread and be valid in all its callbacks.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by KingSnail » Fri May 13, 2011 6:01 pm
Yea but doesnt that create a new newton world?
As far as I understand, in my application, I make NewtonWorld and add bodies to it,
The character controller code does not have anything to do with the world, just manipulates bodies.
Does this mean I need to modify the character controller code in newton folder to save a pointer to the NewtonWorld?
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
by Julio Jerez » Fri May 13, 2011 6:04 pm
The player controller is a joint, and joint has pointer to the body, you can get the body and with teh body you can call NewtonBodyGetWorld()
It is temporary solution until I find out what is wrong, and to see if thsi si what is wrong
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Stucuk » Sat May 14, 2011 1:08 am
KingSnail wrote:Yea but doesnt that create a new newton world?
Delfi just means that you can store the World's Pointer as a global variable and use it for anything that needs it.
-

Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
by KingSnail » Mon May 16, 2011 4:59 am
Well I tried it with the critical section and its causing real weirdness.
Controller seems stuck in the ground now.
I guess I will have to work with 1 Newton thread until theres some sort of bugfix.
Working on an MMORPG powered by Newton Dynamics.
-

KingSnail
-
- Posts: 112
- Joined: Sat Jan 02, 2010 9:55 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest