Author Topic: Vertices only visible in certain camera angles  (Read 4873 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Vertices only visible in certain camera angles
« Reply #15 on: May 31, 2021, 04:59:59 pm »
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...

Offline rkull88

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Vertices only visible in certain camera angles
« Reply #16 on: June 01, 2021, 10:26:22 am »
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

Quote
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...

I'll try thet, thanks!

Offline rkull88

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Vertices only visible in certain camera angles
« Reply #17 on: June 03, 2021, 01:29:55 pm »
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:
Code: [Select]
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:
Code: [Select]
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():
Code: [Select]
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..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Vertices only visible in certain camera angles
« Reply #18 on: June 07, 2021, 02:06:15 pm »
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.