I generate custom geometry the following way:
_grid->BeginGeometry(1, Urho3D::TRIANGLE_STRIP);
_grid->DefineVertex(Urho3D::Vector3(-actualGridSize.x_, 0, -actualGridSize.z_) + _gridOffset);
_grid->DefineColor(COLOR_GRID_MAIN_LINE);
_grid->DefineVertex(Urho3D::Vector3(-actualGridSize.x_, 0, actualGridSize.z_) + _gridOffset);
_grid->DefineColor(COLOR_GRID_MAIN_LINE);
_grid->DefineVertex(Urho3D::Vector3(actualGridSize.x_, 0, -actualGridSize.z_) + _gridOffset);
_grid->DefineColor(COLOR_GRID_MAIN_LINE);
_grid->DefineVertex(Urho3D::Vector3(actualGridSize.x_, 0, actualGridSize.z_) + _gridOffset);
_grid->DefineColor(COLOR_GRID_MAIN_LINE);
_grid->Commit();
The geometry is visible. However I cannot get any results from it when performing a RayOctreeQuery:
Urho3D::IntVector2 mousePos = input->GetMousePosition();
Urho3D::PODVector<Urho3D::RayQueryResult> result;
Urho3D::Ray ray = _camera->GetScreenRay(mousePos.x_, mousePos.y_);
Urho3D::RayOctreeQuery q(result, ray, Urho3D::RAY_TRIANGLE, Urho3D::M_INFINITY, Urho3D::DRAWABLE_GEOMETRY, -1);
_scene->GetComponent<Urho3D::Octree>()->Raycast(q);
if (result.Size() > 0)
{
// do stuff
}
I have also tried using Urho3D::RAY_OBB and Urho3D::DRAWABLE_ANY as well, but still no results. Eventually the mesh that I want to detect will need to be invisible.
One idea I had was to instead use physics objects. Now I don’t need physics simulation in my scene, would it instead be possible to disable the actual physics simulation so that I can simply run my own custom queries against the PhysicsWorld?