A possible bug and it haunts me crazy

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

A possible bug and it haunts me crazy

Post by yanbo2u »

Finally, I can reproduce it.
in LoadContent() function, simply add a box

Code: Select all

Box test0 = new Box(Vector3.UnitY + Vector3.UnitX * 2, 2, 2, 2, 1);
AttachWithSkin(game, test0, CubeBlue);
space.Add(test0);
wait after 5 seconds or more (this is very important).

and then apply an impulse to the box

Code: Select all

if (KeyboardState.IsKeyDown(Keys.Enter) )
{
	Vector3 p0 = Vector3.UnitX * 100 * space.TimeStepSettings.TimeStepDuration;
	test0.ApplyLinearImpulse(ref p0);
}
the box is supposed to accelerate in the direction of X, but it does not move at all.

I looked into the LinearVelocity value of the box, it does increases under impulses, but the position is stationary.

However, if I use another object to shoot at this box test0, it starts moving like waking up by the collision.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: A possible bug and it haunts me crazy

Post by Norbo »

Objects at rest go to sleep to conserve compute resources. ApplyLinearImpulse and ApplyAngularImpulse do not affect the activity state by design; they are direct low-overhead methods used by the solver to change the velocity of the entity.

Changing an entity's properties like LinearMomentum, AngularMomentum, LinearVelocity, or AngularVelocity will wake it up. Note that ApplyLinearImpulse(ref v) is equivalent to entity.LinearMomentum += v.

You can also directly wake up an entity by setting entity.ActivityInformation.IsActive = true.
yanbo2u
Posts: 21
Joined: Sun Oct 04, 2015 4:41 pm

Re: A possible bug and it haunts me crazy

Post by yanbo2u »

ApplyLinearImpulse(ref v) is equivalent to entity.LinearMomentum += v.
Thanks Norbo! It works like a charm.
Post Reply