object still colliding after being removed from space

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
frooze
Posts: 2
Joined: Wed Apr 21, 2010 8:11 am

object still colliding after being removed from space

Post by frooze »

I created a StaticTriangleGroup from a Model like this:

Code: Select all

public StaticTriangleGroup CreateStaticEntityFromModel(Model model)
        {
            StaticTriangleGroup.StaticTriangleGroupVertex[] vertices;
            int[] indices;
            StaticTriangleGroup.getVerticesAndIndicesFromModel(model, out vertices, out indices);
            TriangleMesh triangleMesh = new TriangleMesh(vertices, indices);
            StaticTriangleGroup triangleGroup = new StaticTriangleGroup(triangleMesh);
            return triangleGroup;
        }
then added it to the scene:

Code: Select all

floorPhysics = CreateStaticEntityFromModel(mdl_levelModel);
m_space.add(floorPhysics );
But when i remove it later: m_space.remove(floorPhysics), I realise that other objects are still colliding with it. Is this a bug, or am I doing something wrong? I do not encounter this problem when i use a Box instead of a StaticTriangleGroup.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: object still colliding after being removed from space

Post by Norbo »

This is a known bug; basically, the triangle entities that existed when the StaticTriangleGroup was removed will stay there.

However, as a hacky workaround, you can force it to remove triangles by changing the world matrix of the StaticTriangleGroup to something far away from the colliding objects. The worldMatrix property setter removes any current active triangles, and as long as its new position is clear, no triangles will exist. Then you can safely remove it from the space.

The StaticTriangleGroup, Terrain, and a variety of other components (most of the collision detection system) are undergoing a major overhaul in v0.13.0 which will eliminate this kind of problem completely.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: object still colliding after being removed from space

Post by Norbo »

Also, the upcoming v0.12.1 patch includes a fix which should address this specific problem.
frooze
Posts: 2
Joined: Wed Apr 21, 2010 8:11 am

Re: object still colliding after being removed from space

Post by frooze »

thanks for the quick response! Workaround seems to be working fine... though i'll probably wait for the next release.

Another question, removing an entity from its space is all I need to do to unload it from memory right? (assuming i have no other references anywhere)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: object still colliding after being removed from space

Post by Norbo »

Right; if it's out of the space and it is not referenced anywhere else, it should get collected.
Post Reply