History

wiggly lasers

HifiExperiments committed 2 years ago

Commit 30646471 parent bc45c1715 files · +205 −144Browse files

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

Unified · Split

interface/src/raypick/PickScriptingInterface.cpp+9−1
@@ -121,6 +121,7 @@ PickFilter getPickFilter(unsigned int filter) { · 120 unmodified lines
121121 * @property {Vec3} [dirOffset] - Synonym for <code>direction</code>.
122122 * @property {Quat} [orientation] - Alternative property for specifying <code>direction</code>. The value is applied to the
123123 * default <code>direction</code> value.
124+ * @property {number} [delay=0.0] - The delay, in seconds, to apply to the ray direction.
124125 * @property {PickType} pickType - The type of pick when getting these properties from {@link Picks.getPickProperties} or
125126 * {@link Picks.getPickScriptParameters}. A ray pick's type is {@link PickType.Ray}.
126127 * @property {Vec3} baseScale - Returned from {@link Picks.getPickProperties} when the pick has a parent with varying scale
@@ -173,7 +174,14 @@ std::shared_ptr<PickQuery> PickScriptingInterface::buildRayPick(const QVariantMa · 46 unmodified lines
173174 direction = vec3FromVariant(propMap["dirOffset"]);
174175 }
175176
176− auto rayPick = std::make_shared<RayPick>(position, direction, filter, maxDistance, enabled);
177+ float delayHalf = 0.0f;
178+ if (propMap["delay"].isValid()) {
179+ // We want to be within 0.1% of the target in <delay> seconds
180+ // https://twitter.com/FreyaHolmer/status/1757836988495847568
181+ delayHalf = -std::max(propMap["delay"].toFloat(), 0.0f) / log2(0.001);
182+ }
183+
184+ auto rayPick = std::make_shared<RayPick>(position, direction, filter, maxDistance, delayHalf, enabled);
177185 setParentTransform(rayPick, propMap);
178186
179187 return rayPick;