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
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