History

basic collisions with cubic polyvoxes

Seth Alves committed 11 years ago

Commit 96a40bd1 parent a96520c8 files · +201 −25Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 8 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+37−0
@@ -420,3 +420,40 @@ bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& c · 419 unmodified lines
420420 queueEntityMessage(PacketTypeEntityEdit, entityID, properties);
421421 return true;
422422 }
423+
424+
425+bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) {
426+ if (!_entityTree) {
427+ return false;
428+ }
429+
430+ EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID));
431+ if (!entity) {
432+ qCDebug(entities) << "EntityScriptingInterface::setVoxelSphere no entity with ID" << entityID;
433+ return false;
434+ }
435+
436+ EntityTypes::EntityType entityType = entity->getType();
437+ if (entityType != EntityTypes::PolyVox) {
438+ return false;
439+ }
440+
441+ auto now = usecTimestampNow();
442+
443+ PolyVoxEntityItem* polyVoxEntity = static_cast<PolyVoxEntityItem*>(entity.get());
444+ _entityTree->lockForWrite();
445+ polyVoxEntity->setAll(value);
446+ entity->setLastEdited(now);
447+ entity->setLastBroadcast(now);
448+ _entityTree->unlock();
449+
450+ _entityTree->lockForRead();
451+ EntityItemProperties properties = entity->getProperties();
452+ _entityTree->unlock();
453+
454+ properties.setVoxelDataDirty();
455+ properties.setLastEdited(now);
456+
457+ queueEntityMessage(PacketTypeEntityEdit, entityID, properties);
458+ return true;
459+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t