MyBlockZ - Voxel Engine

Ah that sounds more like the answer i wated to hear :wink:

Ok i am still bug hunting a bit here is my current problem:
Does not work:
[java]

public static void updateCollisionShapeOfTile(final Tile t) {
if (t.getRigid() == null) {
logger.log(Level.WARNING, “No rigidBody; Adding now”);
RigidBodyControl rigid = new RigidBodyControl(0);
t.setRigid(rigid);
if (t.hasVisibleFaces()) {
t.getGeometry().addControl(rigid);
instance.physicSpace.add(rigid);
}
}
if (t.hasVisibleFaces()) {

        final CollisionShape shape = CollisionShapeFactory.createMeshShape(t.getGeometry());
        t.getRigid().setCollisionShape(shape);
    }

}
[/java]

works fine:
[java]

public static void updateCollisionShapeOfTile(final Tile t) {
if (t.getRigid() == null) {
logger.log(Level.WARNING, “No rigidBody; Adding now”);
RigidBodyControl rigid = new RigidBodyControl(0);
t.setRigid(rigid);
if (t.hasVisibleFaces()) {
t.getGeometry().addControl(rigid);
instance.physicSpace.add(rigid);
}
}
if (t.hasVisibleFaces()) {
instance.physicSpace.remove(t.getRigid());
RigidBodyControl rigid = new RigidBodyControl(0);
t.setRigid(rigid);
if (t.hasVisibleFaces()) {
t.getGeometry().addControl(rigid);
instance.physicSpace.add(rigid);
}

    }

}
[/java]

Because its getting more and more a Troubleshooting thread , could we move it? I would create a new thread here with status updates only.

To contribute as plugin, should i start a new thread(in the right section of course)?

I think i would leave it with currently working version and trying to contribute next and fix this (and other bugs) with updates.
Would that be ok?

I love: “Does not work”

It could mean so many things. So I’m going to assume one of them and reply: IMMEDIATELY vacate the building you are in because your machine is about to explode!!!

Ok… it probably wasn’t that one. Which of the literally millions of ways of “not working” is it? Does it crash? Does it blue screen your computer? Does nothing happen? Does it throw an exception?

…useful information to anyone able to help.

Ok sorry for that one… .

The CollisionShape is not updated but left empty ( some times one of the faces works but i could not find out on which condition).
See the effect in this video:

One thing I see in your code is that when you add the rigid body to the tile then you only add the control when it has visible faces. If it didn’t have visible faces the first time then there will never be a control.

Also, if it does have visible faces the first time then you add the control twice in the second case.

This seems like something that could easily be sorted out with some logging and/or a session in the debugger. The logic is definitely strange… which may or may not be the cause… but you having better awareness of what is actually happening in the working and non-working cases would be beneficial anyway.

Yes the “works” state looks now like this:
[java]
if (t.getRigid() != null) {
instance.physicSpace.remove(t.getRigid());
}
if (t.hasVisibleFaces()) {

        RigidBodyControl rigid = new RigidBodyControl(0);
        t.setRigid(rigid);
        if (t.hasVisibleFaces()) {
            t.getGeometry().addControl(rigid);
            instance.physicSpace.add(rigid);
        }
    }

[/java]

But i still have no clue why the case with CollisionShapeFactory does not work.

So now you recreate the rigid body control every time?.. and add it every time?

How many times is this method called (seemed like potentially frequently)?

What does the non-working version look like now? (it was similarly messed up)

I still think you have a logic error. Copious amounts of debug logging would show you.

Ok what i thaught what should work is:

in physicspace ____ has visible faces
1______________1______________update
1______________0______________remove from physicspace
0______________1______________add to physicspace
0______________0______________do nothing

As text:
If the tile is already added to the physicspace and has visible faces -> update collisionshape
If the tile is already added to the physicspace and has no visible faces -> remove from physicspace
If the tile is not added to the physicspace and has visible faces -> add it to physicspace (and update)

My code
[java]
public static void updateCollisionShapeOfTile(final Tile t) {
if (t.getRigid() == null) {
logger.log(Level.WARNING, “No rigidBody; Adding now”);
RigidBodyControl rigid = new RigidBodyControl(0);
t.setRigid(rigid);

    }
    if (t.hasVisibleFaces() && t.getRigid().getPhysicsSpace() == null) {
        System.out.println("vis nospace");
        if (t.getGeometry().getControl(RigidBodyControl.class) == null) {
            System.out.println("geometry has no rigidBody "+t.getRigid());
            t.getGeometry().addControl(t.getRigid());
        }
        instance.physicSpace.add(t.getRigid());

    } else if (!t.hasVisibleFaces() && t.getRigid().getPhysicsSpace() != null) {
        System.out.println("!vis space");
        instance.physicSpace.remove(t.getRigid());
    }
    if (t.hasVisibleFaces() && t.getRigid().getPhysicsSpace() != null) {
        System.out.println("vis space");
        if (t.getGeometry().getControl(RigidBodyControl.class) == null) {
            System.out.println("geometry has no rigidBody "+t.getRigid());
            t.getGeometry().addControl(t.getRigid());
        }

        final CollisionShape shape = CollisionShapeFactory.createMeshShape(t.getGeometry());
        t.getRigid().setCollisionShape(shape);
    }


}

[/java]

But it doesn’t work as well…

I was working on my tile paging until now but this works quite good so i will focus on that problem now.

My first steps to infinite world!
Still lagging but hope some optimization will bring better results.

How is this doing? Is it reusable for other games?