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.
Remove or Replace Box
-
- Posts: 12
- Joined: Tue Jan 17, 2012 10:50 am
Remove or Replace Box
Last edited by galodoido794 on Sun Jan 22, 2012 5:54 pm, edited 1 time in total.
Re: Remove or Replace Box
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.
-
- Posts: 12
- Joined: Tue Jan 17, 2012 10:50 am
Re: Remove or Replace Box
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 ..
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.
Re: Remove or Replace Box
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.
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.
-
- Posts: 12
- Joined: Tue Jan 17, 2012 10:50 am
Re: Remove or Replace Box
Simulate this situation is easy. Just change the part of code:
I'm using the latest version of the Fork.
What happens is that is physically removed, but still designed BOX.
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);
}
}
What happens is that is physically removed, but still designed BOX.
Re: Remove or Replace Box
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.
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.
-
- Posts: 12
- Joined: Tue Jan 17, 2012 10:50 am
Re: Remove or Replace Box
Finally... LOL
Code: Select all
game.ModelDrawer.Remove(entityCollision.Entity);