Skip to content

Commit 4b3a1a6

Browse files
committed
turn whether FindMORay finds children or not into a parameter
1 parent 05cae4e commit 4b3a1a6

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
133133

134134
- `MOSRotating` Lua function `AddWound` now additionally accepts the format `MOSRotating:AddWound(AEmitter* woundToAdd, const Vector& parentOffsetToSet, bool checkGibWoundLimit, bool isEntryWound, bool isExitWound)`, allowing modders to specify added wounds as entry- or exit wounds, for the purpose of not playing multiple burst sounds on the same frame. These new arguments are optional.
135135

136-
- `SceneMan` function `CastFindMORay` now only intersects with and finds the exact MOID specified and not any child MOIDs of that MOID.
136+
- `SceneMan` function `CastFindMORay` now has an extra bool parameter `findChildMOIDs` that denotes whether it also triggers on child MOIDs or not, which defaults to true for the same default behavior as before.
137137

138138
- `SceneMan` function `CastMORay` now can also accept a table of MOIDs instead of a single MOID, letting you ignore any arbitrary set of MOIDs.
139139

Source/Lua/LuaBindingsManagers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, SceneMan) {
331331
.def("CastMORay", &LuaAdaptersSceneMan::CastMORay1)
332332
.def("CastMORay", &LuaAdaptersSceneMan::CastMORay2)
333333
.def("CastAllMOsRay", &LuaAdaptersSceneMan::CastAllMOsRay, luabind::return_stl_iterator)
334+
.def("CastFindMORay", (bool(SceneMan::*)(const Vector&, const Vector&, MOID, const Vector&, unsigned char, bool, int)) & SceneMan::CastFindMORay)
334335
.def("CastFindMORay", &SceneMan::CastFindMORay)
335336
.def("CastObstacleRay", &LuaAdaptersSceneMan::CastObstacleRay1)
336337
.def("CastObstacleRay", &LuaAdaptersSceneMan::CastObstacleRay2)

Source/Managers/SceneMan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ MOID SceneMan::CastMORay(const Vector& start, const Vector& ray, const std::vect
20032003
return g_NoMOID;
20042004
}
20052005

2006-
bool SceneMan::CastFindMORay(const Vector& start, const Vector& ray, MOID targetMOID, Vector& resultPos, unsigned char ignoreMaterial, bool ignoreAllTerrain, int skip) {
2006+
bool SceneMan::CastFindMORay(const Vector& start, const Vector& ray, MOID targetMOID, Vector& resultPos, unsigned char ignoreMaterial, bool ignoreAllTerrain, int skip, bool findChildMOIDs) {
20072007
int hitCount = 0, error, dom, sub, domSteps, skipped = skip;
20082008
int intPos[2], delta[2], delta2[2], increment[2];
20092009
MOID hitMOID = g_NoMOID;
@@ -2065,7 +2065,7 @@ bool SceneMan::CastFindMORay(const Vector& start, const Vector& ray, MOID target
20652065

20662066
// Detect MOIDs
20672067
hitMOID = GetMOIDPixel(intPos[X], intPos[Y], Activity::NoTeam);
2068-
if (hitMOID == targetMOID) {
2068+
if (hitMOID == targetMOID || (findChildMOIDs && hitMOID == g_MovableMan.GetRootMOID(targetMOID))) {
20692069
// Found target MOID, so save result and report success
20702070
resultPos.SetXY(intPos[X], intPos[Y]);
20712071
// Save last ray pos

Source/Managers/SceneMan.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,10 @@ namespace RTE {
699699
/// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0)
700700
/// @param ignoreAllTerrain Whether to ignore all terrain hits or not. (default: false)
701701
/// @param skip For every pixel checked along the line, how many to skip between them (default: 0)
702+
/// @param findChildMOIDs Whether to also find children of the target MOID.
702703
/// for optimization reasons. 0 = every pixel is checked.
703704
/// @return Whether the target MOID was found along the ray or not.
704-
bool CastFindMORay(const Vector& start, const Vector& ray, MOID targetMOID, Vector& resultPos, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false, int skip = 0);
705+
bool CastFindMORay(const Vector& start, const Vector& ray, MOID targetMOID, Vector& resultPos, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false, int skip = 0, bool findChildMOIDs = true);
705706

706707
/// Traces along a vector and returns a vector of all MOs encountered.
707708
/// @param start The starting position.

0 commit comments

Comments
 (0)