Don't use entity scripting interface

This commit is contained in:
Zach Fox 2018-05-02 16:03:50 -07:00
parent 57993cfdd0
commit 900486ed01

View file

@ -13,7 +13,6 @@
#include "SecondaryCamera.h" #include "SecondaryCamera.h"
#include <TextureCache.h> #include <TextureCache.h>
#include <gpu/Context.h> #include <gpu/Context.h>
#include <EntityScriptingInterface.h>
#include <glm/gtx/transform.hpp> #include <glm/gtx/transform.hpp>
using RenderArgsPointer = std::shared_ptr<RenderArgs>; using RenderArgsPointer = std::shared_ptr<RenderArgs>;
@ -35,7 +34,6 @@ public:
using JobModel = render::Job::ModelO<SecondaryCameraJob, RenderArgsPointer, Config>; using JobModel = render::Job::ModelO<SecondaryCameraJob, RenderArgsPointer, Config>;
SecondaryCameraJob() { SecondaryCameraJob() {
_cachedArgsPointer = std::make_shared<RenderArgs>(_cachedArgs); _cachedArgsPointer = std::make_shared<RenderArgs>(_cachedArgs);
_entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
_attachedEntityPropertyFlags += PROP_POSITION; _attachedEntityPropertyFlags += PROP_POSITION;
_attachedEntityPropertyFlags += PROP_ROTATION; _attachedEntityPropertyFlags += PROP_ROTATION;
} }
@ -57,12 +55,16 @@ public:
qWarning() << "ERROR: Cannot set mirror projection for SecondaryCamera without an attachedEntityId set."; qWarning() << "ERROR: Cannot set mirror projection for SecondaryCamera without an attachedEntityId set.";
return; return;
} }
EntityItemPointer attachedEntity = qApp->getEntities()->getTree()->findEntityByID(_attachedEntityId);
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(_attachedEntityId,
_attachedEntityPropertyFlags); if (!attachedEntity) {
glm::vec3 mirrorPropertiesPosition = entityProperties.getPosition(); qWarning() << "ERROR: Cannot get EntityItemPointer for _attachedEntityId.";
glm::quat mirrorPropertiesRotation = entityProperties.getRotation(); return;
glm::vec3 mirrorPropertiesDimensions = entityProperties.getDimensions(); }
glm::vec3 mirrorPropertiesPosition = attachedEntity->getWorldPosition();
glm::quat mirrorPropertiesRotation = attachedEntity->getWorldOrientation();
glm::vec3 mirrorPropertiesDimensions = attachedEntity->getScaledDimensions();
glm::vec3 halfMirrorPropertiesDimensions = 0.5f * mirrorPropertiesDimensions; glm::vec3 halfMirrorPropertiesDimensions = 0.5f * mirrorPropertiesDimensions;
// setup mirror from world as inverse of world from mirror transformation using inverted x and z for mirrored image // setup mirror from world as inverse of world from mirror transformation using inverted x and z for mirrored image
@ -117,10 +119,13 @@ public:
setMirrorProjection(srcViewFrustum); setMirrorProjection(srcViewFrustum);
} else { } else {
if (!_attachedEntityId.isNull()) { if (!_attachedEntityId.isNull()) {
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(_attachedEntityId, EntityItemPointer attachedEntity = qApp->getEntities()->getTree()->findEntityByID(_attachedEntityId);
_attachedEntityPropertyFlags); if (!attachedEntity) {
srcViewFrustum.setPosition(entityProperties.getPosition()); qWarning() << "ERROR: Cannot get EntityItemPointer for _attachedEntityId.";
srcViewFrustum.setOrientation(entityProperties.getRotation()); return;
}
srcViewFrustum.setPosition(attachedEntity->getWorldPosition());
srcViewFrustum.setOrientation(attachedEntity->getWorldOrientation());
} else { } else {
srcViewFrustum.setPosition(_position); srcViewFrustum.setPosition(_position);
srcViewFrustum.setOrientation(_orientation); srcViewFrustum.setOrientation(_orientation);
@ -152,7 +157,6 @@ private:
int _textureHeight; int _textureHeight;
bool _mirrorProjection; bool _mirrorProjection;
EntityPropertyFlags _attachedEntityPropertyFlags; EntityPropertyFlags _attachedEntityPropertyFlags;
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
}; };
void SecondaryCameraJobConfig::setPosition(glm::vec3 pos) { void SecondaryCameraJobConfig::setPosition(glm::vec3 pos) {