Added probe constructor without room number

This commit is contained in:
Lwmte 2025-03-17 23:29:44 +01:00
parent 092346925e
commit 67f4fe3d1d
5 changed files with 17 additions and 10 deletions

View file

@ -122,7 +122,7 @@
<h2><a href="#Functions">Functions</a></h2> <h2><a href="#Functions">Functions</a></h2>
<table class="function_list"> <table class="function_list">
<tr> <tr>
<td class="name" ><a href="#Probe">Probe(pos, roomNumber)</a></td> <td class="name" ><a href="#Probe">Probe(pos[, roomNumber])</a></td>
<td class="summary">Create a Probe at a specified world position in a room.</td> <td class="summary">Create a Probe at a specified world position in a room.</td>
</tr> </tr>
<tr> <tr>
@ -220,7 +220,7 @@
<dl class="function"> <dl class="function">
<dt> <dt>
<a name = "Probe"></a> <a name = "Probe"></a>
<strong>Probe(pos, roomNumber)</strong> <strong>Probe(pos[, roomNumber])</strong>
</dt> </dt>
<dd> <dd>
Create a Probe at a specified world position in a room. Create a Probe at a specified world position in a room.
@ -235,7 +235,8 @@
</li> </li>
<li><span class="parameter">roomNumber</span> <li><span class="parameter">roomNumber</span>
<span class="types"><span class="type">int</span></span> <span class="types"><span class="type">int</span></span>
[opt] Room number. Must be used if probing a position in an overlapping room. Room number. Must be used if probing a position in an overlapping room.
(<em>optional</em>)
</li> </li>
</ul> </ul>

View file

@ -517,7 +517,7 @@
<ul> <ul>
<li><span class="parameter">objectCollision</span> <li><span class="parameter">objectCollision</span>
<span class="types"><span class="type">bool</span></span> <span class="types"><span class="type">bool</span></span>
when enabled, camera will collide with moveables and statics. Disable or TR4-like camera behaviour. when enabled, camera will collide with moveables and statics. Disable for TR4-like camera behaviour.
</li> </li>
</ul> </ul>

View file

@ -26,6 +26,7 @@ namespace TEN::Scripting::Collision
void Probe::Register(sol::table& parent) void Probe::Register(sol::table& parent)
{ {
using ctors = sol::constructors< using ctors = sol::constructors<
Probe(const Vec3&),
Probe(const Vec3&, int), Probe(const Vec3&, int),
Probe(const Vec3&, int, const Vec3&, float), Probe(const Vec3&, int, const Vec3&, float),
Probe(const Vec3&, int, const Rotation&, float), Probe(const Vec3&, int, const Rotation&, float),
@ -65,13 +66,17 @@ namespace TEN::Scripting::Collision
/// Create a Probe at a specified world position in a room. /// Create a Probe at a specified world position in a room.
// @function Probe // @function Probe
// @tparam Vec3 pos World position. // @tparam Vec3 pos World position.
// @tparam int roomNumber[opt] Room number. Must be used if probing a position in an overlapping room. // @tparam[opt] int roomNumber Room number. Must be used if probing a position in an overlapping room.
// @treturn Probe A new Probe. // @treturn Probe A new Probe.
Probe::Probe(const Vec3& pos, TypeOrNil<int> roomNumber) Probe::Probe(const Vec3& pos)
{ {
auto convertedPos = pos.ToVector3i(); auto convertedPos = pos.ToVector3i();
int roomNumberValue = ValueOr<int>(roomNumber, FindRoomNumber(convertedPos)); _pointCollision = GetPointCollision(convertedPos, FindRoomNumber(convertedPos));
_pointCollision = GetPointCollision(convertedPos, roomNumberValue); }
Probe::Probe(const Vec3& pos, int roomNumber)
{
_pointCollision = GetPointCollision(pos.ToVector3i(), roomNumber);
} }
/// Create a Probe that casts from an origin world position in a room in a given direction for a specified distance. /// Create a Probe that casts from an origin world position in a room in a given direction for a specified distance.

View file

@ -31,7 +31,8 @@ namespace TEN::Scripting::Collision
// Constructors // Constructors
Probe() = default; Probe() = default;
Probe(const Vec3& pos, TypeOrNil<int> roomNumber); Probe(const Vec3& pos);
Probe(const Vec3& pos, int roomNumber);
Probe(const Vec3& origin, int roomNumber, const Vec3& dir, float dist); Probe(const Vec3& origin, int roomNumber, const Vec3& dir, float dist);
Probe(const Vec3& origin, int roomNumber, const Rotation& rot, float dist); Probe(const Vec3& origin, int roomNumber, const Rotation& rot, float dist);
Probe(const Vec3& origin, int roomNumber, const Rotation& rot, const Vec3& relOffset); Probe(const Vec3& origin, int roomNumber, const Rotation& rot, const Vec3& relOffset);

View file

@ -124,7 +124,7 @@ namespace TEN::Scripting
"lasersightLightColor", &CameraSettings::LasersightLightColor, "lasersightLightColor", &CameraSettings::LasersightLightColor,
/// Specify whether camera can collide with objects. /// Specify whether camera can collide with objects.
// @tfield bool objectCollision when enabled, camera will collide with moveables and statics. Disable or TR4-like camera behaviour. // @tfield bool objectCollision when enabled, camera will collide with moveables and statics. Disable for TR4-like camera behaviour.
"objectCollision", &CameraSettings::ObjectCollision); "objectCollision", &CameraSettings::ObjectCollision);
} }