MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / PickMoveable

Function PickMoveable

TombEngine/Scripting/Internal/TEN/Util/Util.cpp:190–201  ·  view source on GitHub ↗

Pick a moveable by the given display position. @function PickMoveableByDisplayPosition @tparam Vec2 position Display space position in percent. @treturn Objects.Moveable Picked moveable (nil if no moveable was found under the cursor). @usage -- Example: Pick a moveable at the center of the screen. local screenCenter = TEN.Vec2(50, 50) local pickedMoveable = TEN.Util.PickMoveableByDisplayPosition(s

Source from the content-addressed store, hash-verified

188 // print("No moveable found at the center of the screen.")
189 // end
190 static sol::optional <std::unique_ptr<Moveable>> PickMoveable(const Vec2& screenPos)
191 {
192 auto ray = GetRayFrom2DPosition(PercentToScreen(screenPos));
193
194 auto vector = Vector3i::Zero;
195 int itemNumber = ObjectOnLOS2(&ray.first, &ray.second, &vector, nullptr);
196
197 if (itemNumber == NO_LOS_ITEM || itemNumber < 0)
198 return sol::nullopt;
199
200 return std::make_unique<Moveable>(itemNumber);
201 }
202
203 /// Pick a static mesh by the given display position.
204 // @function PickStaticByDisplayPosition

Callers

nothing calls this directly

Calls 3

GetRayFrom2DPositionFunction · 0.85
PercentToScreenFunction · 0.85
ObjectOnLOS2Function · 0.85

Tested by

no test coverage detected