History

lockEnd, editRenderState, and updated grab.js

SamGondelman committed 9 years ago

Commit bf243d61 parent 912b4177 files · +190 −111Browse files

Showing the changes to interface/src/raypick/LaserPointerScriptingInterface.cpp (1 of 7 files). Show all

Unified · Split

interface/src/raypick/LaserPointerScriptingInterface.cpp+59−30
@@ -40,6 +40,11 @@ uint32_t LaserPointerScriptingInterface::createLaserPointer(const QVariant& prop · 39 unmodified lines
4040 centerEndY = propertyMap["centerEndY"].toBool();
4141 }
4242
43+ bool lockEnd = false;
44+ if (propertyMap["lockEnd"].isValid()) {
45+ lockEnd = propertyMap["lockEnd"].toBool();
46+ }
47+
4348 bool enabled = false;
4449 if (propertyMap["enabled"].isValid()) {
4550 enabled = propertyMap["enabled"].toBool();
@@ -53,33 +58,7 @@ uint32_t LaserPointerScriptingInterface::createLaserPointer(const QVariant& prop · 7 unmodified lines
5358 QVariantMap renderStateMap = renderStateVariant.toMap();
5459 if (renderStateMap["name"].isValid()) {
5560 QString name = renderStateMap["name"].toString();
56−
57− QUuid startID;
58− if (renderStateMap["start"].isValid()) {
59− QVariantMap startMap = renderStateMap["start"].toMap();
60− if (startMap["type"].isValid()) {
61− startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap);
62− }
63− }
64−
65− QUuid pathID;
66− if (renderStateMap["path"].isValid()) {
67− QVariantMap pathMap = renderStateMap["path"].toMap();
68− // right now paths must be line3ds
69− if (pathMap["type"].isValid() && pathMap["type"].toString() == "line3d") {
70− pathID = qApp->getOverlays().addOverlay(pathMap["type"].toString(), pathMap);
71− }
72− }
73−
74− QUuid endID;
75− if (renderStateMap["end"].isValid()) {
76− QVariantMap endMap = renderStateMap["end"].toMap();
77− if (endMap["type"].isValid()) {
78− endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap);
79− }
80− }
81−
82− renderStates[name] = RenderState(startID, pathID, endID);
61+ renderStates[name] = buildRenderState(renderStateMap);
8362 }
8463 }
8564 }
@@ -100,9 +79,9 @@ uint32_t LaserPointerScriptingInterface::createLaserPointer(const QVariant& prop · 14 unmodified lines
10079 dirOffset = vec3FromVariant(propertyMap["dirOffset"]);
10180 }
10281
103− return DependencyManager::get<LaserPointerManager>()->createLaserPointer(jointName, posOffset, dirOffset, filter, maxDistance, renderStates, faceAvatar, centerEndY, enabled);
82+ return DependencyManager::get<LaserPointerManager>()->createLaserPointer(jointName, posOffset, dirOffset, filter, maxDistance, renderStates, faceAvatar, centerEndY, lockEnd, enabled);
10483 } else {
105− return DependencyManager::get<LaserPointerManager>()->createLaserPointer(filter, maxDistance, renderStates, faceAvatar, centerEndY, enabled);
84+ return DependencyManager::get<LaserPointerManager>()->createLaserPointer(filter, maxDistance, renderStates, faceAvatar, centerEndY, lockEnd, enabled);
10685 }
10786 } else if (propertyMap["position"].isValid()) {
10887 glm::vec3 position = vec3FromVariant(propertyMap["position"]);
@@ -112,8 +91,58 @@ uint32_t LaserPointerScriptingInterface::createLaserPointer(const QVariant& prop · 3 unmodified lines
11291 direction = vec3FromVariant(propertyMap["direction"]);
11392 }
11493
115− return DependencyManager::get<LaserPointerManager>()->createLaserPointer(position, direction, filter, maxDistance, renderStates, faceAvatar, centerEndY, enabled);
94+ return DependencyManager::get<LaserPointerManager>()->createLaserPointer(position, direction, filter, maxDistance, renderStates, faceAvatar, centerEndY, lockEnd, enabled);
11695 }
11796
11897 return 0;
98+}
99+
100+void LaserPointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) {
101+ QVariantMap propMap = properties.toMap();
102+
103+ QVariant startProps;
104+ if (propMap["start"].isValid()) {
105+ startProps = propMap["start"];
106+ }
107+
108+ QVariant pathProps;
109+ if (propMap["path"].isValid()) {
110+ pathProps = propMap["path"];
111+ }
112+
113+ QVariant endProps;
114+ if (propMap["end"].isValid()) {
115+ endProps = propMap["end"];
116+ }
117+
118+ DependencyManager::get<LaserPointerManager>()->editRenderState(uid, renderState, startProps, pathProps, endProps);
119+}
120+
121+const RenderState LaserPointerScriptingInterface::buildRenderState(const QVariantMap& propMap) {
122+ QUuid startID;
123+ if (propMap["start"].isValid()) {
124+ QVariantMap startMap = propMap["start"].toMap();
125+ if (startMap["type"].isValid()) {
126+ startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap);
127+ }
128+ }
129+
130+ QUuid pathID;
131+ if (propMap["path"].isValid()) {
132+ QVariantMap pathMap = propMap["path"].toMap();
133+ // right now paths must be line3ds
134+ if (pathMap["type"].isValid() && pathMap["type"].toString() == "line3d") {
135+ pathID = qApp->getOverlays().addOverlay(pathMap["type"].toString(), pathMap);
136+ }
137+ }
138+
139+ QUuid endID;
140+ if (propMap["end"].isValid()) {
141+ QVariantMap endMap = propMap["end"].toMap();
142+ if (endMap["type"].isValid()) {
143+ endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap);
144+ }
145+ }
146+
147+ return RenderState(startID, pathID, endID);
119148 }