mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
more ray picking and intersection work
This commit is contained in:
parent
70a4ff1e75
commit
802f72c732
2 changed files with 18 additions and 0 deletions
|
@ -4101,6 +4101,7 @@ void Application::loadScript(const QString& fileNameString) {
|
|||
// setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
|
||||
// we can use the same ones from the application.
|
||||
scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender);
|
||||
scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree());
|
||||
scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
|
||||
scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
|
||||
|
||||
|
|
|
@ -44,5 +44,22 @@ void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale
|
|||
|
||||
RayToVoxelIntersectionResult VoxelsScriptingInterface::findRayIntersection(const PickRay& ray) {
|
||||
RayToVoxelIntersectionResult result;
|
||||
if (_tree) {
|
||||
if (_tree->tryLockForRead()) {
|
||||
OctreeElement* element;
|
||||
result.intersects = _tree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face);
|
||||
if (result.intersects) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
result.voxel.x = voxel->getCorner().x;
|
||||
result.voxel.y = voxel->getCorner().y;
|
||||
result.voxel.z = voxel->getCorner().z;
|
||||
result.voxel.s = voxel->getScale();
|
||||
result.voxel.red = voxel->getColor()[0];
|
||||
result.voxel.green = voxel->getColor()[1];
|
||||
result.voxel.blue = voxel->getColor()[2];
|
||||
}
|
||||
_tree->unlock();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue