Jump to content

[SOLVED] getIntersection() with dynamically created mesh


photo

Recommended Posts

World::getIntersection with dynamically created mesh dose not work

test code is here

--------------------------------

        auto mesh = ObjectMeshDynamic::create();
        mesh->allocateVertex(4);
        mesh->allocateIndices(6);
        mesh->addVertex(vec3(0, 0, 1));
        mesh->addVertex(vec3(1, 0, 1));
        mesh->addVertex(vec3(1, 1, 1));
        mesh->addVertex(vec3(0, 1, 1));
        mesh->addIndex(0);
        mesh->addIndex(1);
        mesh->addIndex(2);
        mesh->addIndex(0);
        mesh->addIndex(2);
        mesh->addIndex(3);
        mesh->addSurface("mat0");
        mesh->setIntersection(true, 0);
        mesh->setIntersectionMask(1, 0);
        mesh->updateTangents();
        mesh->updateBounds();

        
        auto obj = World::getIntersection(vec3(0.5, 0.5, 2), vec3(0.5, 0.5, 0), 1);
        if (obj)
        {
            Log::message("hit\n");
        }

Link to comment

Hello! 

have you tried to call World::updateSpatial after node creation? 

As a new node becomes a part of the BSP tree only after the updateSpatial()method is called (the engine calls the method automatically each frame after the world script update()code is executed), all engine subsystems can process this node only in the next frame.

Link to comment
  • silent changed the title to [SOLVED] getIntersection() with dynamically created mesh
×
×
  • Create New...