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

Function PickStatic

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

Pick a static mesh by the given display position. @function PickStaticByDisplayPosition @tparam Vec2 position Display space position in percent. @treturn Objects.Static Picked static mesh (nil if no static mesh was found under the cursor). @usage -- Example: Pick a static mesh at the center of the screen. local screenCenter = TEN.Vec2(50, 50) local pickedStatic = TEN.Util.PickStaticByDisplayPositi

Source from the content-addressed store, hash-verified

214 // print("No static mesh found at the center of the screen.")
215 // end
216 static sol::optional <std::unique_ptr<Static>> PickStatic(const Vec2& screenPos)
217 {
218 auto ray = GetRayFrom2DPosition(PercentToScreen(screenPos));
219
220 StaticMesh* mesh = nullptr;
221 auto vector = Vector3i::Zero;
222 int itemNumber = ObjectOnLOS2(&ray.first, &ray.second, &vector, &mesh, GAME_OBJECT_ID::ID_LARA);
223
224 if (itemNumber == NO_LOS_ITEM || itemNumber >= 0)
225 return sol::nullopt;
226
227 return std::make_unique<Static>(*mesh);
228 }
229
230 /// Write messages within the Log file.<br>
231 // For native Lua handling of errors, see <a href="https://www.lua.org/pil/8.3.html">Error management</a> and <a href="https://www.lua.org/manual/5.4/manual.html#pdf-debug.traceback">debug.traceback</a>

Callers

nothing calls this directly

Calls 3

GetRayFrom2DPositionFunction · 0.85
PercentToScreenFunction · 0.85
ObjectOnLOS2Function · 0.85

Tested by

no test coverage detected