Issue in 0.10.1

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Fax3D
Posts: 22
Joined: Mon Sep 29, 2008 7:42 am

Issue in 0.10.1

Post by Fax3D »

Hi Norbo,

i found an issue in some situation: when i call space.update() i get "Object not set on an instance of the object... try to use new keyword bla bla bla". This error doesn't appear after a specific action on physics, but sometimes appear... probabily in the update routines there's a null not tested i don't know... This happens both in multithreading or single threading scenario.

Ok, this is just to tell you there's this issue!

Thanks.

Fax3D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Issue in 0.10.1

Post by Norbo »

Could you copy and paste the exception details? There should be some information about where the exception is occurring in the update. I may also need a reproduction case depending on the exception.
Fax3D
Posts: 22
Joined: Mon Sep 29, 2008 7:42 am

Re: Issue in 0.10.1

Post by Fax3D »

Hi Norbo,

this is the detail of the exception...

System.NullReferenceException was unhandled
Message="Riferimento a un oggetto non impostato su un'istanza di oggetto."
Source="BEPUphysics"
StackTrace:
in BEPUphysics.Entities.Entity.applyForces(Single dt, Single timeScale)
in BEPUphysics.Space.applyForcesMultithreadedSubFunction(Object information)
in BEPUphysics.ThreadManager.WorkerThread.threadExecutionLoop()
in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
in System.Threading.ThreadHelper.ThreadStart()
InnerException:

Thanks!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Issue in 0.10.1

Post by Norbo »

Make sure that the entity's forces list is not null, and that it contains no null forces. Another possibility is that the entity was somehow removed from the space at a bad time, perhaps because the engine is running asynchronously. This second possibility is very hard to make happen, though.
smhillis
Posts: 3
Joined: Fri Sep 04, 2009 1:13 am

Re: Issue in 0.10.1

Post by smhillis »

Yeah I am getting the same thing. I am trying to do the GettingStarted tutorial and it crashes when I put in space.update(gameTime);
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Issue in 0.10.1

Post by Norbo »

I think that might be a different crash; make sure that the space field of your game is instantiated and not a local variable also called space in your LoadContent method.

For example, the following will throw an exception:

Code: Select all

Space space;

void LoadContent()
{
    Space space = new Space();
}

void Update(GameTime gameTime)
{
    space.update(gameTime);
}
The game's 'space' field is null because the LoadContent's space variable hides the game's variable.

If this isn't the issue, could you copy and paste the detail of the exception you're getting?
smhillis
Posts: 3
Joined: Fri Sep 04, 2009 1:13 am

Re: Issue in 0.10.1

Post by smhillis »

Yeah that was my error. So I should put the
Space space = new Space();
into Update then?
Thanks
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Issue in 0.10.1

Post by Norbo »

Putting it into the Update would create a new, different Space every single frame, which is not what you want.

Instead, you should instantiate the game's space variable. It's very similar to the previous example:

Code: Select all

Space space;

void LoadContent()
{
    space = new Space();
}

void Update(GameTime gameTime)
{
    space.update(gameTime);
}
The only difference is that the space referred to by the LoadContent method is the game's space, not a local variable.
smhillis
Posts: 3
Joined: Fri Sep 04, 2009 1:13 am

Re: Issue in 0.10.1

Post by smhillis »

I see, thanks
Post Reply