Report any bugs here and we'll post fixes
Moderators: Sascha Willems, Thomas
by Aphex » Thu Sep 18, 2008 5:32 pm
hey,
I've just moved over from a user collision to a heightmap collision (NewtonCreateHeightFieldCollision).
I set the heightmap collision user ID to a specific value on creation, but when I iterate over all bodies (NewtonWorldGetFirst/NextBody) and check their collision ID, I don't appear to ever get back the ID value I set..?
[ed] In fact, the user ID value I get back for the island looks more like a pointer (for instance 0x05d7e180 in my last run...)
-
Aphex
-
- Posts: 144
- Joined: Fri Jun 18, 2004 6:08 am
- Location: UK
-
by Julio Jerez » Fri Sep 19, 2008 7:36 am
can you post a code fragement?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Aphex » Fri Sep 19, 2008 10:38 am
okeys:
Set up collision:
- Code: Select all
// New heightfield collision:
char* attributes = new char[mHeightMap->Width()*mHeightMap->Height()];
STATIC_CHECK(sizeof(unsigned short)==sizeof(THeightVal)); // fn below takes unsigned shorts for height vals.
NewtonCollision* collision = NewtonCreateHeightFieldCollision(physWorld, mHeightMap->Width(), mHeightMap->Height(), 1, (unsigned short*)mHeightMap->DataPtr(), attributes, KIslandScale, mHeightScale);
NewtonStaticCollisionSetDebugCallback(collision, HeightfieldCollisionDebugCallback);
delete [] attributes;
NewtonConvexCollisionSetUserID(collision, NPhysEng::KCollisionIdIsland); <- KCollisionIdIsland = 37
mPhysicsBody = NewtonCreateBody(physWorld, collision);
NewtonReleaseCollision (physWorld, collision);
NewtonBodySetUserData(mPhysicsBody, this);
NewtonBodySetMaterialGroupID(mPhysicsBody, NMaterials::IdFromType(NMaterials::EEarth));
const TMatrix4d orient(WorldPos()-TWorldPos(mHeightMap->Width()*0.5*KIslandScale-7, -mHeightOffset, mHeightMap->Height()*0.5*KIslandScale-7)); // origin at top left...
#endif
NewtonBodySetMatrix(mPhysicsBody, orient.Ptr());
Get user id back:
- Code: Select all
NewtonBody* body = NULL;
for (body=NewtonWorldGetFirstBody(mPhysicsWorld) ; body!=NULL ; body=NewtonWorldGetNextBody(mPhysicsWorld, body))
{
GFXAPI().SetColor3f(NewtonBodyGetFreezeState(body)==0 ? TColor::Red() : TColor(0.5f, 0.0f, 0.0f));
TMatrix4d matrix;
NewtonBodyGetMatrix(body, matrix.Ptr());
NewtonCollision* collision = NewtonBodyGetCollision(body);
const unsigned int userId = NewtonConvexCollisionGetUserID(collision); // <-- Get back what looks like a ptr here!
if (userId!=KCollisionIdIsland || (userId==KCollisionIdIsland && gPhysEngShowIslandCollision))
{
NewtonCollisionForEachPolygonDo(collision, matrix.Ptr(), DebugShowGeometryCollision, NULL);
}
}
-
Aphex
-
- Posts: 144
- Joined: Fri Jun 18, 2004 6:08 am
- Location: UK
-
by Julio Jerez » Fri Sep 19, 2008 11:24 am
Oh I see whu the does no work.
Th ereason is that teh user teh collision object has a userdat type,
The type is a pointer I have to do that fo 64 bit compibility, bacause in soem plaform teh sized of pointe and inter an dlon ios differen tehref ro I use a usnion to make aligment consistent.
This si the problem copmbe collision use teh user dat atyeop to store a collision ID because all of teh faces have uniform properies.
poligonal meshes collision use user ID as a proinet to point to teh array and array of using dat ato stre the ID for each face and a hold bunch of other data.
I guess I can add anoeth member to store teh user data for collision trees,
can you use this function:
NewtonCollisionInfoRecord info;
NewtonCollisionGetInfo (collision, &info);
Edit:
I was wondering how can I made a mistake liek that, but that is no a mistake if you look carefullt the function name tells you taht collision ID can only be set on convex collision.
I can leave the userdata as it is, and add a new data id, then change the interface for
NewtonConvexCollisionSetUserID to NewtonCollisionSetUserID
does that sound like a solution
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Fri Sep 19, 2008 12:23 pm
Ok I made the fix id Fix, using this NewtonConvexCollisionSetUserID to NewtonCollisionSetUserID
are you using the win64 or double?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Aphex » Fri Sep 19, 2008 2:16 pm
Yeah I did wonder about the 'convex' bit in the name, but then saw it was used in the sdk demos.
I'm using the double version
I've got a workaround in place though, so I can live with it for a bit
[ed] whoops it wasn't in a demo - I think I just kept it around from the user collision I was using previously
Last edited by
Aphex on Fri Sep 19, 2008 3:10 pm, edited 1 time in total.
-
Aphex
-
- Posts: 144
- Joined: Fri Jun 18, 2004 6:08 am
- Location: UK
-
by Julio Jerez » Fri Sep 19, 2008 2:44 pm
Liek I said, I made teh chane alread
can you hold until I public the next Beta?
I was ocupid with other personal life issues, but now I am spending time finishing one of the the two features.
I beleive it will come to the rescue of the preblem you are having know with the car and the terrain.
I am hopping to have ready this weekend.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Aphex » Fri Sep 19, 2008 3:06 pm
Excellent - I can hold out
Hope your life issues aren't bad ones.
-
Aphex
-
- Posts: 144
- Joined: Fri Jun 18, 2004 6:08 am
- Location: UK
-
Return to Bugs and Fixes
Who is online
Users browsing this forum: No registered users and 3 guests