Hey, I'm using the CC3Ray to which node had been touched.
CC3Ray touchRay = [self.activeCamera unprojectPoint: touchPoint];
CC3NodePuncturingVisitor* puncturedNodes = [self nodesIntersectedByGlobalRay: touchRay];
CC3Node* localNode = puncturedNodes.closestPuncturedNode;
every now and then the nodes in the scene have there vertices change. I do so by updating the GLBuffers like so:
[aMesh updateGLBuffersStartingAt:0 forLength:i];
[aMesh.vertexIndices updateGLBufferStartingAt:0 forLength:i];
So for a quick example, say that there was a box in the scene, after the touch, the top face of that box gets its vertices changed, the top face is now at twice the height it was at before, new faces are also added along the sides of the box so that the box doesn't have any holes after the top of the face was moved up. In the end the Box becomes a Rectangle.
Another touch is applied onto the top face of the node, but this time the CC3Ray does not detect the touch!
It happens because the
boundingVolume wasn't updated. I invoked the following method after updating the mesh:
[myNode setBoundingVolume:[myNode defaultBoundingVolume]];
but creating the bounding volume again creates a performance hit (sometimes dropping to half the average fps) . Is there any way to get around that?
maybe I could update the boundingVoume instead of recreating it?
I'm no longer going to use
CC3Node nodesIntersectedByGlobalRay: , after some test the touch detection become extremely inaccurate.
It wasn't the node selection that was inaccurate, there was a variable that I wasn't updating in my code which made the selection inaccurate.