mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Added script API methods for static mesh collision
This commit is contained in:
parent
f2d7044dfb
commit
edf3fbf68f
9 changed files with 99 additions and 4 deletions
|
@ -45,7 +45,8 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
|
||||||
* Added `Effects.EmitStreamer` function to emit streamers.
|
* Added `Effects.EmitStreamer` function to emit streamers.
|
||||||
* Added `Flow.GetTotalSecretCount` function to get total amount of secrets in the game.
|
* Added `Flow.GetTotalSecretCount` function to get total amount of secrets in the game.
|
||||||
* Added `View.GetFlyByPosition` and `View.GetFlyByRotation` functions to get flyby sequence parameters at a specified time point.
|
* Added `View.GetFlyByPosition` and `View.GetFlyByRotation` functions to get flyby sequence parameters at a specified time point.
|
||||||
* Added `Moveable:GetScale` and `Movebale:SetScale` methods to set visible scale of moveables.
|
* Added `Moveable:GetScale` and `Movebale:SetScale` methods to get or set visible scale of moveables.
|
||||||
|
* Added `Static:GetCollidable` and `Static:SetCollidable` methods to get or set collision status of static meshes.
|
||||||
* Added `Rotation:Lerp` function to allow linear interpolation between rotations.
|
* Added `Rotation:Lerp` function to allow linear interpolation between rotations.
|
||||||
* Added ability to perform additive and subtractive operations on `Rotation` class and compare one `Rotation` to another.
|
* Added ability to perform additive and subtractive operations on `Rotation` class and compare one `Rotation` to another.
|
||||||
* Added various `Translate` methods to `Vec2` and `Vec3` script objects.
|
* Added various `Translate` methods to `Vec2` and `Vec3` script objects.
|
||||||
|
|
|
@ -390,7 +390,7 @@
|
||||||
poison = <span class="keyword">false</span>,
|
poison = <span class="keyword">false</span>,
|
||||||
burn = <span class="keyword">false</span>,
|
burn = <span class="keyword">false</span>,
|
||||||
damageHit = <span class="number">80</span>,
|
damageHit = <span class="number">80</span>,
|
||||||
sound = <span class="number">197</span>,
|
soundID = <span class="number">197</span>,
|
||||||
light = <span class="keyword">true</span>,
|
light = <span class="keyword">true</span>,
|
||||||
lightRadius = <span class="number">6</span>,
|
lightRadius = <span class="number">6</span>,
|
||||||
lightFlicker = <span class="number">5</span>,
|
lightFlicker = <span class="number">5</span>,
|
||||||
|
|
|
@ -156,6 +156,10 @@
|
||||||
<td class="summary">Get this static's visibility status.</td>
|
<td class="summary">Get this static's visibility status.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="name" ><a href="#Static:GetCollidable">Static:GetCollidable()</a></td>
|
||||||
|
<td class="summary">Get this static's collision status.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<td class="name" ><a href="#Static:GetSolid">Static:GetSolid()</a></td>
|
<td class="name" ><a href="#Static:GetSolid">Static:GetSolid()</a></td>
|
||||||
<td class="summary">Get this static's solid collision status.</td>
|
<td class="summary">Get this static's solid collision status.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -192,6 +196,10 @@
|
||||||
<td class="summary">Set this static's solid collision status.</td>
|
<td class="summary">Set this static's solid collision status.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="name" ><a href="#Static:SetCollidable">Static:SetCollidable(collidable)</a></td>
|
||||||
|
<td class="summary">Set this static's collision status.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<td class="name" ><a href="#Static:Enable">Static:Enable()</a></td>
|
<td class="name" ><a href="#Static:Enable">Static:Enable()</a></td>
|
||||||
<td class="summary">Enable this static.</td>
|
<td class="summary">Enable this static.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -379,6 +387,27 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Static:GetCollidable"></a>
|
||||||
|
<strong>Static:GetCollidable()</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Get this static's collision status.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Returns:</h3>
|
||||||
|
<ol>
|
||||||
|
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
Collision status. <strong>true: can be collided with</strong>, <strong>false: no collision</strong>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
<a name = "Static:GetSolid"></a>
|
<a name = "Static:GetSolid"></a>
|
||||||
|
@ -576,6 +605,28 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "Static:SetCollidable"></a>
|
||||||
|
<strong>Static:SetCollidable(collidable)</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
Set this static's collision status.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Parameters:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">collidable</span>
|
||||||
|
<span class="types"><span class="type">bool</span></span>
|
||||||
|
New collision status. <strong>true: can be collided with</strong>, <strong>false: no collision</strong>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
<dt>
|
<dt>
|
||||||
<a name = "Static:Enable"></a>
|
<a name = "Static:Enable"></a>
|
||||||
|
|
|
@ -946,6 +946,10 @@ void CollideSolidStatics(ItemInfo* item, CollisionInfo* coll)
|
||||||
if (!(mesh.flags & StaticMeshFlags::SM_VISIBLE))
|
if (!(mesh.flags & StaticMeshFlags::SM_VISIBLE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Bypass static meshes which are marked as non-collidable.
|
||||||
|
if (!(mesh.flags & StaticMeshFlags::SM_COLLISION))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Only process meshes which are solid, or if solid mode is set by the setup.
|
// Only process meshes which are solid, or if solid mode is set by the setup.
|
||||||
if (!coll->Setup.ForceSolidStatics && !(mesh.flags & StaticMeshFlags::SM_SOLID))
|
if (!coll->Setup.ForceSolidStatics && !(mesh.flags & StaticMeshFlags::SM_SOLID))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1894,9 +1898,14 @@ void DoObjectCollision(ItemInfo* item, CollisionInfo* coll)
|
||||||
|
|
||||||
for (auto& staticObject : neighborRoom.mesh)
|
for (auto& staticObject : neighborRoom.mesh)
|
||||||
{
|
{
|
||||||
|
// Check if static is visible.
|
||||||
if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE))
|
if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Check if static is collidable.
|
||||||
|
if (!(staticObject.flags & StaticMeshFlags::SM_COLLISION))
|
||||||
|
continue;
|
||||||
|
|
||||||
// For Lara, solid static mesh collisions are directly managed by GetCollisionInfo,
|
// For Lara, solid static mesh collisions are directly managed by GetCollisionInfo,
|
||||||
// so we bypass them here to avoid interference.
|
// so we bypass them here to avoid interference.
|
||||||
if (isPlayer && (staticObject.flags & StaticMeshFlags::SM_SOLID))
|
if (isPlayer && (staticObject.flags & StaticMeshFlags::SM_SOLID))
|
||||||
|
|
|
@ -705,6 +705,10 @@ std::optional<Vector3> GetStaticObjectLos(const Vector3& origin, int roomNumber,
|
||||||
if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE))
|
if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Check if static is collidable.
|
||||||
|
if (!(staticObject.flags & StaticMeshFlags::SM_COLLISION))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Check if static is solid (if applicable).
|
// Check if static is solid (if applicable).
|
||||||
if (onlySolid && !(staticObject.flags & StaticMeshFlags::SM_SOLID))
|
if (onlySolid && !(staticObject.flags & StaticMeshFlags::SM_SOLID))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -37,8 +37,9 @@ enum RoomEnvFlags
|
||||||
|
|
||||||
enum StaticMeshFlags : short
|
enum StaticMeshFlags : short
|
||||||
{
|
{
|
||||||
SM_VISIBLE = 1,
|
SM_VISIBLE = (1 << 0),
|
||||||
SM_SOLID = 2
|
SM_SOLID = (1 << 1),
|
||||||
|
SM_COLLISION = (1 << 2)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ROOM_VERTEX
|
struct ROOM_VERTEX
|
||||||
|
|
|
@ -474,6 +474,7 @@ constexpr char ScriptReserved_StaticGetPosition[] = "GetPosition";
|
||||||
constexpr char ScriptReserved_StaticGetRotation[] = "GetRotation";
|
constexpr char ScriptReserved_StaticGetRotation[] = "GetRotation";
|
||||||
constexpr char ScriptReserved_StaticGetScale[] = "GetScale";
|
constexpr char ScriptReserved_StaticGetScale[] = "GetScale";
|
||||||
constexpr char ScriptReserved_StaticGetSlot[] = "GetSlot";
|
constexpr char ScriptReserved_StaticGetSlot[] = "GetSlot";
|
||||||
|
constexpr char ScriptReserved_StaticGetCollidable[] = "GetCollidable";
|
||||||
constexpr char ScriptReserved_StaticGetSolid[] = "GetSolid";
|
constexpr char ScriptReserved_StaticGetSolid[] = "GetSolid";
|
||||||
constexpr char ScriptReserved_StaticSetColor[] = "SetColor";
|
constexpr char ScriptReserved_StaticSetColor[] = "SetColor";
|
||||||
constexpr char ScriptReserved_StaticSetHitPoints[] = "SetHP";
|
constexpr char ScriptReserved_StaticSetHitPoints[] = "SetHP";
|
||||||
|
@ -483,6 +484,7 @@ constexpr char ScriptReserved_StaticSetRotation[] = "SetRotation";
|
||||||
constexpr char ScriptReserved_StaticSetScale[] = "SetScale";
|
constexpr char ScriptReserved_StaticSetScale[] = "SetScale";
|
||||||
constexpr char ScriptReserved_StaticSetSlot[] = "SetSlot";
|
constexpr char ScriptReserved_StaticSetSlot[] = "SetSlot";
|
||||||
constexpr char ScriptReserved_StaticSetSolid[] = "SetSolid";
|
constexpr char ScriptReserved_StaticSetSolid[] = "SetSolid";
|
||||||
|
constexpr char ScriptReserved_StaticSetCollidable[] = "SetCollidable";
|
||||||
constexpr char ScriptReserved_StaticShatter[] = "Shatter";
|
constexpr char ScriptReserved_StaticShatter[] = "Shatter";
|
||||||
|
|
||||||
// =====
|
// =====
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace TEN::Scripting
|
||||||
ScriptReserved_StaticGetColor, &Static::GetColor,
|
ScriptReserved_StaticGetColor, &Static::GetColor,
|
||||||
ScriptReserved_StaticGetHP, &Static::GetHitPoints, // TODO: Deprecate.
|
ScriptReserved_StaticGetHP, &Static::GetHitPoints, // TODO: Deprecate.
|
||||||
ScriptReserved_StaticGetActive, &Static::GetActiveStatus, // TODO: Deprecate. Rename Lua func to GetActiveStatus.
|
ScriptReserved_StaticGetActive, &Static::GetActiveStatus, // TODO: Deprecate. Rename Lua func to GetActiveStatus.
|
||||||
|
ScriptReserved_StaticGetCollidable, &Static::GetCollidable,
|
||||||
ScriptReserved_StaticGetSolid, &Static::GetSolidStatus, // TODO: Deprecate. Rename Lua func to GetSolidStatus.
|
ScriptReserved_StaticGetSolid, &Static::GetSolidStatus, // TODO: Deprecate. Rename Lua func to GetSolidStatus.
|
||||||
|
|
||||||
ScriptReserved_StaticSetName, &Static::SetName,
|
ScriptReserved_StaticSetName, &Static::SetName,
|
||||||
|
@ -47,6 +48,7 @@ namespace TEN::Scripting
|
||||||
ScriptReserved_StaticSetScale, &Static::SetScale,
|
ScriptReserved_StaticSetScale, &Static::SetScale,
|
||||||
ScriptReserved_StaticSetColor, &Static::SetColor,
|
ScriptReserved_StaticSetColor, &Static::SetColor,
|
||||||
ScriptReserved_StaticSetHitPoints, &Static::SetHitPoints, // TODO: Deprecate. Rename Lua func to SetHitPoints.
|
ScriptReserved_StaticSetHitPoints, &Static::SetHitPoints, // TODO: Deprecate. Rename Lua func to SetHitPoints.
|
||||||
|
ScriptReserved_StaticSetCollidable, &Static::SetCollidable,
|
||||||
ScriptReserved_StaticSetSolid, &Static::SetSolidStatus, // TODO: Deprecate. Rename Lua func to SetSolidStatus.
|
ScriptReserved_StaticSetSolid, &Static::SetSolidStatus, // TODO: Deprecate. Rename Lua func to SetSolidStatus.
|
||||||
|
|
||||||
ScriptReserved_StaticEnable, &Static::Enable,
|
ScriptReserved_StaticEnable, &Static::Enable,
|
||||||
|
@ -123,6 +125,14 @@ namespace TEN::Scripting
|
||||||
return ((_static.flags & StaticMeshFlags::SM_VISIBLE) != 0);
|
return ((_static.flags & StaticMeshFlags::SM_VISIBLE) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get this static's collision status.
|
||||||
|
// @function Static:GetCollidable
|
||||||
|
// @treturn bool Collision status. __true: can be collided with__, __false: no collision__
|
||||||
|
bool Static::GetCollidable() const
|
||||||
|
{
|
||||||
|
return ((_static.flags & StaticMeshFlags::SM_COLLISION) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
/// Get this static's solid collision status.
|
/// Get this static's solid collision status.
|
||||||
// @function Static:GetSolid
|
// @function Static:GetSolid
|
||||||
// @treturn bool Solid Status. __true: solid__, __false: soft__
|
// @treturn bool Solid Status. __true: solid__, __false: soft__
|
||||||
|
@ -219,6 +229,21 @@ namespace TEN::Scripting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set this static's collision status.
|
||||||
|
// @function Static:SetCollidable
|
||||||
|
// @tparam bool collidable New collision status. __true: can be collided with__, __false: no collision__
|
||||||
|
void Static::SetCollidable(bool collidable)
|
||||||
|
{
|
||||||
|
if (collidable)
|
||||||
|
{
|
||||||
|
_static.flags |= StaticMeshFlags::SM_COLLISION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_static.flags &= ~StaticMeshFlags::SM_COLLISION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Enable this static. Used when previously shattered disabled manually.
|
/// Enable this static. Used when previously shattered disabled manually.
|
||||||
// @function Static:Enable
|
// @function Static:Enable
|
||||||
void Static::Enable()
|
void Static::Enable()
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace TEN::Scripting
|
||||||
ScriptColor GetColor() const;
|
ScriptColor GetColor() const;
|
||||||
int GetHitPoints() const;
|
int GetHitPoints() const;
|
||||||
bool GetActiveStatus() const;
|
bool GetActiveStatus() const;
|
||||||
|
bool GetCollidable() const;
|
||||||
bool GetSolidStatus() const;
|
bool GetSolidStatus() const;
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
|
@ -56,6 +57,7 @@ namespace TEN::Scripting
|
||||||
void SetScale(float scale);
|
void SetScale(float scale);
|
||||||
void SetColor(const ScriptColor& color);
|
void SetColor(const ScriptColor& color);
|
||||||
void SetHitPoints(int hitPoints);
|
void SetHitPoints(int hitPoints);
|
||||||
|
void SetCollidable(bool status);
|
||||||
void SetSolidStatus(bool status);
|
void SetSolidStatus(bool status);
|
||||||
|
|
||||||
// Utilities
|
// Utilities
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue