Vertices only visible in certain camera angles

Started by rkull88, May 17, 2021, 01:17:17 PM

Previous topic - Next topic

EgonOlsen

You might want to try to apply the controller just once, remove it and call build afterwards. Just to see if that changes something. It shouldn't, but just to rule that out...

rkull88

Nothing superscientific done, but ran an average on the different setups in the onDraw() method in my fragment. Measuring the time it takes to update the vertices.

Vertex controller: 35 ms
Vertex attribute: 9 ms

But for the rendering itself (no averaging, just looking at the time spent):

Vertex controller: mostly around 100 ms
Vertex attributes: mostly around 200 ms

QuoteYou might want to try to apply the controller just once, remove it and call build afterwards. Just to see if that changes something. It shouldn't, but just to rule that out...

I'll try thet, thanks!

rkull88

Maybe I'm doing something incorrect cause I can't get the triangles to be drawn/updated when assigning controller, applying, removing and then calling build. Here's what I do:

int vertexCount = object.getMesh().getUniqueVertexCount();

JpctVertexController2 controller = new JpctVertexController2();
object.getMesh().setVertexController(controller, true);

JpctMeshData initData = new JpctMeshData(vertexCount);
controller.updateMeshData(initData.vertexData, initData.normalData);
object.getMesh().applyVertexController();
object.touch();
object.getMesh().removeVertexController();

object.build();
world.addObject(object);


where JpctMeshData is just initialized as:

public JpctMeshData(int size) {
        vertexData = new SimpleVector[size];
        normalData = new SimpleVector[size];

        for(int i = 0; i < vertexData.length; i++) {
            vertexData[i] = new SimpleVector();
            normalData[i] = new SimpleVector(0, -1, 0);
        }
    }


and controller.updateMeshData():

public synchronized void updateMeshData(SimpleVector[] meshData, SimpleVector[] normalData) {
        SimpleVector[] destinationMesh = getDestinationMesh();
        SimpleVector[] destinationNormals = getDestinationNormals();
        System.arraycopy(meshData, 0, destinationMesh, 0, meshData.length);
        System.arraycopy(normalData, 0, destinationNormals, 0, normalData.length);
    }


Had the same problem earlier. That's why I had to keep the controller but only update it the first time and then continue by only updating the attributes..

EgonOlsen

That's a bit strange. The vertex controller does nothing more than to modify the mesh. Whether this happens via controller at runtime or it's by baking it into the mesh shouldn't matter.