Jump to content

  • Log In with Google      Sign In   
  • Create Account

physics unhandeled exception


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Adam West   Members   -  Reputation: 219

Like
0Likes
Like

Posted 28 June 2012 - 01:27 AM

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

Sponsor:

#2 doeme   Members   -  Reputation: 707

Like
0Likes
Like

Posted 28 June 2012 - 01:44 AM

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

#3 Adam West   Members   -  Reputation: 219

Like
0Likes
Like

Posted 28 June 2012 - 02:33 AM

ive changed it a bit but ithink the problem is

physxManager

->

simulate

(

TimeElapsed

);



here is the updated code


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

[color=#666600][size=2][left][background=rgb(250, 251, 252)]void PhysicsManager::StepPhysics()
{[/background][/left][/size][/color]
[color=#666600][size=2][left][background=rgb(250, 251, 252)]float TimeElapsed = FindElapsedTime();[/background][/left][/size][/color]
[color=#666600][size=2][left][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));


}



#4 Ashaman73   Crossbones+   -  Reputation: 7512

Like
0Likes
Like

Posted 28 June 2012 - 03:52 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS