• Advertisement
Sign in to follow this  

physics unhandeled exception

This topic is 2034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey there,

for my game i am trying to implement a method wich will be called in the game loop to calculate the physics. the time elapsed is required. for some reason which is unknown to me i keep getting and unhandeled exception? what is wrong with the code?



void PhysicsManager::StepPhysics()
{

// Get frame delta time: NOT WORKING
const u32 time_now = device->getTimer()->getTime();
const f32 frameDeltaTime = (f32)(time_now-time_then)/1000.f; // Time in seconds: /1000.f
time_then = time_now;

// Set the physics simulation going
physxManager->simulate(TimeElapsed);

// Wait for the physics simulation to finish
physxManager->fetchResults();

// Render Physx debug data
physxManager->renderDebugData(video::SColor(225,255,255,255));


}


time_then is defined elsewhere as the time from when the program began

Share this post


Link to post
Share on other sites
Advertisement
Where exactly do you get your unhandled exception at which line? Step through the code with a debugger to find out. In my experience unhandled exceptions are often nullptr-exception. Assuming u32 and f32 are primitive dataypes the calculation itself is *very* unlikely to throw an exception.

On the other hand seems you're not using frameDeltaTime at all, so why calculate it? Should "TimeElapsed" be "frameDeltaTime"?

Share this post


Link to post
Share on other sites
ive changed it a bit but ithink the problem is [color=#000000][size=2]

[background=rgb(250, 251, 252)]physxManager[/background]

[color=#666600][size=2]

[background=rgb(250, 251, 252)]->[/background]

[color=#000000][size=2]

[background=rgb(250, 251, 252)]simulate[/background]

[color=#666600][size=2]

[background=rgb(250, 251, 252)]([/background]

[color=#660066][size=2]

[background=rgb(250, 251, 252)]TimeElapsed[/background]

[color=#666600][size=2]

[background=rgb(250, 251, 252)]);[/background]



[color=#666600][size=2]

[background=rgb(250, 251, 252)]here is the updated code[/background]


[color=#666600][size=2]

[background=rgb(250, 251, 252)]
float redNovember::FindElapsedTime()
{
irr::u32 now = device->getTimer()->getTime();
irr::f32 TimeElapsed = (now - then) / 1000.f; // seconds
then = now;[/background]


[color=#666600][size=2]

[background=rgb(250, 251, 252)]return now;[/background]



[color=#666600][size=2]

[background=rgb(250, 251, 252)]void PhysicsManager::StepPhysics()
{[/background]


[color=#666600][size=2]

[background=rgb(250, 251, 252)]float TimeElapsed = FindElapsedTime();[/background]


[color=#666600][size=2]

[background=rgb(250, 251, 252)] // Set the physics simulation going
physxManager->simulate(TimeElapsed);

// Wait for the physics simulation to finish
physxManager->fetchResults();

// Render Physx debug data
physxManager->renderDebugData(video::SColor(225,255,255,255));


}
[/background]

Share this post


Link to post
Share on other sites
I don't think that the problem is at this line of code, more likely that physx has not been initialized correctly or contained invalid data.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement