Remove or Replace Box

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
galodoido794
Posts: 12
Joined: Tue Jan 17, 2012 10:50 am

Remove or Replace Box

Post by galodoido794 »

I must be very beginner hehehe I'm having a Box remove the space.
For example:

var = entityCollision raycastResult.HitObject the EntityCollidable;
Box box = (Box) entityCollision.Entity;
Space.Remove (box):

It seems that he was physically removed, but the design it is not removed ...

What is the best approach for this?

What I'm trying to do is remove the box and put another in his place with other features. I'm researching how do I put a new box without impacting the neighbors Box.
Last edited by galodoido794 on Sun Jan 22, 2012 5:54 pm, edited 1 time in total.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Remove or Replace Box

Post by Norbo »

Do you mean the graphic is not removed? Since the physics engine has no knowledge or understanding of graphics, removing something from the Space will not affect any related graphics system. The graphics system in use must be notified of the change somehow.
galodoido794
Posts: 12
Joined: Tue Jan 17, 2012 10:50 am

Re: Remove or Replace Box

Post by galodoido794 »

I do not know if there is any problem to get the entity class EntityCollidable ...

I was debugging and noticed that it happened in about six methods remove (in Space), but did not remove the design but only the physical

I'm still thinking about what can be ..
Last edited by galodoido794 on Sun Jan 22, 2012 6:01 pm, edited 1 time in total.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Remove or Replace Box

Post by Norbo »

Sorry, I'm not sure what you mean.

Is it throwing exceptions when you try to cast the BroadPhaseEntry to an EntityCollidable? If the thing hit by the ray is not an EntityCollidable, that will happen; the type should be tested before attempting to cast it. Same thing for the box entity, though you do not need to cast to a Box to remove it from the Space; the Space understands what an entity is.
galodoido794
Posts: 12
Joined: Tue Jan 17, 2012 10:50 am

Re: Remove or Replace Box

Post by galodoido794 »

Simulate this situation is easy. Just change the part of code:

Code: Select all

 
                    if (Space.RayCast(new Ray(game.Camera.Position, game.Camera.WorldMatrix.Forward), 1000, rayCastFilter, out raycastResult))
                    {
                        var entityCollision = raycastResult.HitObject as EntityCollidable;
                        if (entityCollision != null && entityCollision.Entity.IsDynamic)
                        {
                                Box b = (Box)entityCollision.Entity;
                                Space.Remove(b);
                       }
                    }
I'm using the latest version of the Fork.
What happens is that is physically removed, but still designed BOX.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Remove or Replace Box

Post by Norbo »

What do you expect to occur, and what is happening that is different?

If I use that code in the demos right-click ray cast, I get the expected result- if it hits a dynamic entity, it tries to remove it from the space. If it's not a Box entity, it crashes. If it is a Box, it's removed from the space, but the graphic remains in place because the space knows nothing about graphics.
galodoido794
Posts: 12
Joined: Tue Jan 17, 2012 10:50 am

Re: Remove or Replace Box

Post by galodoido794 »

Finally... LOL

Code: Select all

game.ModelDrawer.Remove(entityCollision.Entity);
Post Reply