History

Merge branch 'master' into safe-teleport-target

sabrina-shanman committed 8 years ago

Commit 870940b2 parents a460cfa 3a6a72a402 files · +12792 −7790Browse files

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

Unified · Split

interface/src/raypick/PickScriptingInterface.cpp+100−0
@@ -18,6 +18,9 @@ · 17 unmodified lines
1818 #include "JointRayPick.h"
1919 #include "MouseRayPick.h"
2020 #include "StylusPick.h"
21+#include "StaticParabolaPick.h"
22+#include "JointParabolaPick.h"
23+#include "MouseParabolaPick.h"
2124 #include "CollisionPick.h"
2225
2326 #include <ScriptEngine.h>
@@ -28,6 +31,8 @@ unsigned int PickScriptingInterface::createPick(const PickQuery::PickType type, · 4 unmodified lines
2831 return createRayPick(properties);
2932 case PickQuery::PickType::Stylus:
3033 return createStylusPick(properties);
34+ case PickQuery::PickType::Parabola:
35+ return createParabolaPick(properties);
3136 case PickQuery::PickType::Collision:
3237 return createCollisionPick(properties);
3338 default:
@@ -138,6 +143,101 @@ unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties · 104 unmodified lines
138143 return DependencyManager::get<PickManager>()->addPick(PickQuery::Stylus, std::make_shared<StylusPick>(side, filter, maxDistance, enabled));
139144 }
140145
146+/**jsdoc
147+ * A set of properties that can be passed to {@link Picks.createPick} to create a new Parabola Pick.
148+ * @typedef {object} Picks.ParabolaPickProperties
149+ * @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results.
150+ * @property {number} [filter=Picks.PICK_NOTHING] The filter for this Pick to use, constructed using filter flags combined using bitwise OR.
151+ * @property {number} [maxDistance=0.0] The max distance at which this Pick will intersect. 0.0 = no max. < 0.0 is invalid.
152+ * @property {string} [joint] Only for Joint or Mouse Parabola Picks. If "Mouse", it will create a Parabola Pick that follows the system mouse, in desktop or HMD.
153+ * If "Avatar", it will create a Joint Parabola Pick that follows your avatar's head. Otherwise, it will create a Joint Parabola Pick that follows the given joint, if it
154+ * exists on your current avatar.
155+ * @property {Vec3} [posOffset=Vec3.ZERO] Only for Joint Parabola Picks. A local joint position offset, in meters. x = upward, y = forward, z = lateral
156+ * @property {Vec3} [dirOffset=Vec3.UP] Only for Joint Parabola Picks. A local joint direction offset. x = upward, y = forward, z = lateral
157+ * @property {Vec3} [position] Only for Static Parabola Picks. The world-space origin of the parabola segment.
158+ * @property {Vec3} [direction=-Vec3.FRONT] Only for Static Parabola Picks. The world-space direction of the parabola segment.
159+ * @property {number} [speed=1] The initial speed of the parabola, i.e. the initial speed of the projectile whose trajectory defines the parabola.
160+ * @property {Vec3} [accelerationAxis=-Vec3.UP] The acceleration of the parabola, i.e. the acceleration of the projectile whose trajectory defines the parabola, both magnitude and direction.
161+ * @property {boolean} [rotateAccelerationWithAvatar=true] Whether or not the acceleration axis should rotate with your avatar's local Y axis.
162+ * @property {boolean} [scaleWithAvatar=false] If true, the velocity and acceleration of the Pick will scale linearly with your avatar.
163+ */
164+unsigned int PickScriptingInterface::createParabolaPick(const QVariant& properties) {
165+ QVariantMap propMap = properties.toMap();
166+
167+ bool enabled = false;
168+ if (propMap["enabled"].isValid()) {
169+ enabled = propMap["enabled"].toBool();
170+ }
171+
172+ PickFilter filter = PickFilter();
173+ if (propMap["filter"].isValid()) {
174+ filter = PickFilter(propMap["filter"].toUInt());
175+ }
176+
177+ float maxDistance = 0.0f;
178+ if (propMap["maxDistance"].isValid()) {
179+ maxDistance = propMap["maxDistance"].toFloat();
180+ }
181+
182+ float speed = 1.0f;
183+ if (propMap["speed"].isValid()) {
184+ speed = propMap["speed"].toFloat();
185+ }
186+
187+ glm::vec3 accelerationAxis = -Vectors::UP;
188+ if (propMap["accelerationAxis"].isValid()) {
189+ accelerationAxis = vec3FromVariant(propMap["accelerationAxis"]);
190+ }
191+
192+ bool rotateAccelerationWithAvatar = true;
193+ if (propMap["rotateAccelerationWithAvatar"].isValid()) {
194+ rotateAccelerationWithAvatar = propMap["rotateAccelerationWithAvatar"].toBool();
195+ }
196+
197+ bool scaleWithAvatar = false;
198+ if (propMap["scaleWithAvatar"].isValid()) {
199+ scaleWithAvatar = propMap["scaleWithAvatar"].toBool();
200+ }
201+
202+ if (propMap["joint"].isValid()) {
203+ std::string jointName = propMap["joint"].toString().toStdString();
204+
205+ if (jointName != "Mouse") {
206+ // x = upward, y = forward, z = lateral
207+ glm::vec3 posOffset = Vectors::ZERO;
208+ if (propMap["posOffset"].isValid()) {
209+ posOffset = vec3FromVariant(propMap["posOffset"]);
210+ }
211+
212+ glm::vec3 dirOffset = Vectors::UP;
213+ if (propMap["dirOffset"].isValid()) {
214+ dirOffset = vec3FromVariant(propMap["dirOffset"]);
215+ }
216+
217+ return DependencyManager::get<PickManager>()->addPick(PickQuery::Parabola, std::make_shared<JointParabolaPick>(jointName, posOffset, dirOffset,
218+ speed, accelerationAxis, rotateAccelerationWithAvatar,
219+ scaleWithAvatar, filter, maxDistance, enabled));
220+
221+ } else {
222+ return DependencyManager::get<PickManager>()->addPick(PickQuery::Parabola, std::make_shared<MouseParabolaPick>(speed, accelerationAxis, rotateAccelerationWithAvatar,
223+ scaleWithAvatar, filter, maxDistance, enabled));
224+ }
225+ } else if (propMap["position"].isValid()) {
226+ glm::vec3 position = vec3FromVariant(propMap["position"]);
227+
228+ glm::vec3 direction = -Vectors::FRONT;
229+ if (propMap["direction"].isValid()) {
230+ direction = vec3FromVariant(propMap["direction"]);
231+ }
232+
233+ return DependencyManager::get<PickManager>()->addPick(PickQuery::Parabola, std::make_shared<StaticParabolaPick>(position, direction, speed, accelerationAxis,
234+ rotateAccelerationWithAvatar, scaleWithAvatar,
235+ filter, maxDistance, enabled));
236+ }
237+
238+ return PickManager::INVALID_PICK_ID;
239+}
240+
141241 /**jsdoc
142242 * A Shape defines a physical volume.
143243 *

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