Crash in Newton dll when using setPositionOrientation

e04margu

25-05-2006 11:02:51

Hello.
I've searched both these and the newton forums for topics on this but I only found a few threads and most of them were solved in ways I have tried without results or they never got any replies.

So here comes the explanation.
I'm working on a sort of fps game and I have a pool of ogrenewt bodies that I'm re-using for projectiles. When they hit the walls or whatever I set their collision to null and hide the graphics by detaching the scenenode from it's parent.
When the player fires I set the collision back to the original one (a simple sphere shape), unfreeze the body, re-attach the scenenode and set the position and velocity of the projectile.

The problem I think is with setPositionOrientation. Sometimes this makes the projectile appear inside other newton bodies if the player is standing close to a wall or there are many projectiles created at the same time for some reason (we have some exploding stuff that does that). When this happens newton crashes in the dll and there is no call stack or debug info to get any help so I'm stumped.

I really hope it's something I did because I really don't want to add extra checks with raycasts or whatever to make sure I don't move objects inside of each other. Seems rather redundant IMO.

I am using setPositionOrientation from inside collision callbacks in some cases btw. Read something about some functions being dangerous to call from inside some callbacks but I also read this one should be ok. Please tell me if that's the problem and if you have any good workarounds for it. I already moved some code out of the callbacks with some flag setting, don't really like that method of doing things though.

//Markus

e04margu

25-05-2006 14:51:05

Ok I couldn't be bothered to wait for a reply since I have had this issue for days now.
Guess I should have posted this earlier ;)
Anyway, I tried moving setPositionOrientation out of the callbacks by temporary storing the new position value and setting an update flag and then applying it in my update function which is run right after the physics update and that seems to have resolved the issue.

I'm not very happy with this though since I read in some other thread over at the newton forum that this issue has been resolved for a long time and you should be able to use setPositionOrientation from inside a collision callback.

I haven't done very extensive testing yet so I can't guarantee I just solved my own problem. I guess I will change this post or reply again here if it's still bugged.

And if not, I hope this will help someone that is having the same problems.