mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Initial commit
This commit is contained in:
parent
6ef9675bcb
commit
1ee44ca291
35 changed files with 417 additions and 352 deletions
|
@ -67,6 +67,18 @@ void LaraControl(ItemInfo* item, CollisionInfo* coll)
|
|||
{
|
||||
auto& player = GetLaraInfo(*item);
|
||||
|
||||
auto& room = g_Level.Rooms[item->RoomNumber];
|
||||
for (auto& staticObj : room.mesh)
|
||||
{
|
||||
if (IsClicked(In::Action))
|
||||
staticObj.Transform.Scale.z += 0.1f;
|
||||
else if (IsClicked(In::Walk))
|
||||
staticObj.Transform.Scale.z -= 0.1f;
|
||||
staticObj.Dirty = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Alert nearby creatures.
|
||||
if (player.Control.Weapon.HasFired)
|
||||
{
|
||||
|
|
|
@ -1575,7 +1575,7 @@ void HandleProjectile(ItemInfo& projectile, ItemInfo& emitter, const Vector3i& p
|
|||
hasHit = hasHitNotByEmitter = doShatter = true;
|
||||
doExplosion = isExplosive;
|
||||
|
||||
if (Statics[staticPtr->staticNumber].shatterType == ShatterType::None)
|
||||
if (Statics[staticPtr->ObjectId].shatterType == ShatterType::None)
|
||||
continue;
|
||||
|
||||
staticPtr->HitPoints -= damage;
|
||||
|
@ -1585,8 +1585,8 @@ void HandleProjectile(ItemInfo& projectile, ItemInfo& emitter, const Vector3i& p
|
|||
if (!isExplosive)
|
||||
continue;
|
||||
|
||||
TriggerExplosionSparks(staticPtr->pos.Position.x, staticPtr->pos.Position.y, staticPtr->pos.Position.z, 3, -2, 0, projectile.RoomNumber);
|
||||
auto pose = Pose(Vector3i(staticPtr->pos.Position.x, staticPtr->pos.Position.y - 128, staticPtr->pos.Position.z), EulerAngles(0, staticPtr->pos.Orientation.y, 0));
|
||||
TriggerExplosionSparks(staticPtr->Transform.Position.x, staticPtr->Transform.Position.y, staticPtr->Transform.Position.z, 3, -2, 0, projectile.RoomNumber);
|
||||
auto pose = Pose(Vector3i(staticPtr->Transform.Position.x, staticPtr->Transform.Position.y - 128, staticPtr->Transform.Position.z), EulerAngles(0, staticPtr->Transform.Orientation.y, 0));
|
||||
TriggerShockwave(&pose, 40, 176, 64, 0, 96, 128, 16, EulerAngles::Identity, 0, true, false, false, (int)ShockwaveStyle::Normal);
|
||||
}
|
||||
|
||||
|
|
41
TombEngine/Game/StaticObject.cpp
Normal file
41
TombEngine/Game/StaticObject.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "framework.h"
|
||||
|
||||
#include "Game/Setup.h"
|
||||
|
||||
//namespace TEN
|
||||
//{
|
||||
GameBoundingBox MESH_INFO::GetAabb(bool getVisibilityAabb) const
|
||||
{
|
||||
static auto bounds = GameBoundingBox();
|
||||
|
||||
if (getVisibilityAabb)
|
||||
{
|
||||
bounds = Statics[ObjectId].visibilityBox;
|
||||
}
|
||||
else
|
||||
{
|
||||
bounds = Statics[ObjectId].collisionBox;
|
||||
}
|
||||
|
||||
auto center = bounds.GetCenter();
|
||||
auto extents = bounds.GetExtents();
|
||||
auto scaledExtents = extents * Transform.Scale;
|
||||
auto scaledOffset = (center * Transform.Scale) - center;
|
||||
|
||||
bounds.X1 = (center.x - scaledExtents.x) + scaledOffset.x;
|
||||
bounds.X2 = (center.x + scaledExtents.x) + scaledOffset.x;
|
||||
bounds.Y1 = (center.y - scaledExtents.y) + scaledOffset.y;
|
||||
bounds.Y2 = (center.y + scaledExtents.y) + scaledOffset.y;
|
||||
bounds.Z1 = (center.z - scaledExtents.z) + scaledOffset.z;
|
||||
bounds.Z2 = (center.z + scaledExtents.z) + scaledOffset.z;
|
||||
return bounds;
|
||||
}
|
||||
|
||||
GameBoundingBox& GetBoundsAccurate(const MESH_INFO& staticObj, bool getVisibilityBox)
|
||||
{
|
||||
static auto bounds = GameBoundingBox();
|
||||
|
||||
bounds = staticObj.GetAabb(getVisibilityBox);
|
||||
return bounds;
|
||||
}
|
||||
//}
|
38
TombEngine/Game/StaticObject.h
Normal file
38
TombEngine/Game/StaticObject.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include "Math/Math.h"
|
||||
#include "Objects/objectslist.h"
|
||||
|
||||
using namespace TEN::Math;
|
||||
|
||||
enum GAME_OBJECT_ID : short;
|
||||
|
||||
// TODO: Come up with a namespace.
|
||||
//namespace TEN
|
||||
//{
|
||||
enum StaticMeshFlags
|
||||
{
|
||||
SM_VISIBLE = 1 << 0,
|
||||
SM_SOLID = 1 << 1
|
||||
};
|
||||
|
||||
// class StaticObject
|
||||
struct MESH_INFO
|
||||
{
|
||||
std::string Name = {};
|
||||
//int Id = 0; // TODO: Store static ID.
|
||||
GAME_OBJECT_ID ObjectId = GAME_OBJECT_ID::ID_NO_OBJECT;
|
||||
|
||||
Pose Transform = Pose::Zero;
|
||||
int RoomNumber = 0;
|
||||
Color Color = SimpleMath::Color();
|
||||
|
||||
int HitPoints = 0;
|
||||
int Flags = 0;
|
||||
bool Dirty = false;
|
||||
|
||||
GameBoundingBox GetAabb(bool getVisibilityAabb) const; // TODO: Use DX BoundingBox natively.
|
||||
};
|
||||
|
||||
GameBoundingBox& GetBoundsAccurate(const MESH_INFO& staticObj, bool getVisibilityBox);
|
||||
//}
|
|
@ -1409,11 +1409,11 @@ static std::vector<int> FillCollideableItemList()
|
|||
|
||||
bool CheckStaticCollideCamera(MESH_INFO* mesh)
|
||||
{
|
||||
bool isCloseEnough = Vector3i::Distance(mesh->pos.Position, Camera.pos.ToVector3i()) <= COLL_CHECK_THRESHOLD;
|
||||
bool isCloseEnough = Vector3i::Distance(mesh->Transform.Position, Camera.pos.ToVector3i()) <= COLL_CHECK_THRESHOLD;
|
||||
if (!isCloseEnough)
|
||||
return false;
|
||||
|
||||
if (!(mesh->flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(mesh->Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
return false;
|
||||
|
||||
const auto& bounds = GetBoundsAccurate(*mesh, false);
|
||||
|
@ -1500,18 +1500,18 @@ void ItemsCollideCamera()
|
|||
if (!mesh)
|
||||
return;
|
||||
|
||||
auto distance = Vector3i::Distance(mesh->pos.Position, LaraItem->Pose.Position);
|
||||
auto distance = Vector3i::Distance(mesh->Transform.Position, LaraItem->Pose.Position);
|
||||
if (distance > COLL_CANCEL_THRESHOLD)
|
||||
continue;
|
||||
|
||||
auto bounds = GetBoundsAccurate(*mesh, false);
|
||||
if (TestBoundsCollideCamera(bounds, mesh->pos, CAMERA_RADIUS))
|
||||
ItemPushCamera(&bounds, &mesh->pos, RADIUS);
|
||||
if (TestBoundsCollideCamera(bounds, mesh->Transform, CAMERA_RADIUS))
|
||||
ItemPushCamera(&bounds, &mesh->Transform, RADIUS);
|
||||
|
||||
if (DebugMode)
|
||||
{
|
||||
DrawDebugBox(
|
||||
bounds.ToBoundingOrientedBox(mesh->pos),
|
||||
bounds.ToBoundingOrientedBox(mesh->Transform),
|
||||
Vector4(1.0f, 0.0f, 0.0f, 1.0f), RendererDebugPage::CollisionStats);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,11 +199,11 @@ CollidedObjectData GetCollidedObjects(ItemInfo& collidingItem, bool onlyVisible,
|
|||
for (auto& staticObj : neighborRoom.mesh)
|
||||
{
|
||||
// Discard invisible statics.
|
||||
if (!(staticObj.flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(staticObj.Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
continue;
|
||||
|
||||
// Test rough distance to discard statics beyond collision check threshold.
|
||||
float dist = Vector3i::Distance(staticObj.pos.Position, collidingItem.Pose.Position);
|
||||
float dist = Vector3i::Distance(staticObj.Transform.Position, collidingItem.Pose.Position);
|
||||
if (dist > COLLISION_CHECK_DISTANCE)
|
||||
continue;
|
||||
|
||||
|
@ -213,12 +213,12 @@ CollidedObjectData GetCollidedObjects(ItemInfo& collidingItem, bool onlyVisible,
|
|||
continue;
|
||||
|
||||
// Test conservative AABB intersection.
|
||||
auto aabb = bounds.ToConservativeBoundingBox(staticObj.pos);
|
||||
auto aabb = bounds.ToConservativeBoundingBox(staticObj.Transform);
|
||||
if (!aabb.Intersects(collidingAabb))
|
||||
continue;
|
||||
|
||||
// Test accurate OBB intersection.
|
||||
auto obb = bounds.ToBoundingOrientedBox(staticObj.pos.Position);
|
||||
auto obb = bounds.ToBoundingOrientedBox(staticObj.Transform.Position);
|
||||
if (obb.Intersects(convertedBounds))
|
||||
collObjects.Statics.push_back(&staticObj);
|
||||
}
|
||||
|
@ -312,12 +312,12 @@ void TestForObjectOnLedge(ItemInfo* item, CollisionInfo* coll)
|
|||
|
||||
for (auto& mesh : g_Level.Rooms[i].mesh)
|
||||
{
|
||||
if (!(mesh.flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(mesh.Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
continue;
|
||||
|
||||
if (Vector3i::Distance(item->Pose.Position, mesh.pos.Position) < COLLISION_CHECK_DISTANCE)
|
||||
if (Vector3i::Distance(item->Pose.Position, mesh.Transform.Position) < COLLISION_CHECK_DISTANCE)
|
||||
{
|
||||
const auto& bBox = GetBoundsAccurate(mesh, false).ToBoundingOrientedBox(mesh.pos);
|
||||
const auto& bBox = GetBoundsAccurate(mesh, false).ToBoundingOrientedBox(mesh.Transform);
|
||||
float distance;
|
||||
|
||||
if (bBox.Intersects(origin, direction, distance) && distance < (coll->Setup.Radius * 2))
|
||||
|
@ -600,17 +600,17 @@ bool TestBoundsCollideStatic(ItemInfo* item, const MESH_INFO& mesh, int radius)
|
|||
return false;
|
||||
|
||||
const auto& itemBounds = GetBestFrame(*item).BoundingBox;
|
||||
if (mesh.pos.Position.y + bounds.Y2 <= item->Pose.Position.y + itemBounds.Y1)
|
||||
if (mesh.Transform.Position.y + bounds.Y2 <= item->Pose.Position.y + itemBounds.Y1)
|
||||
return false;
|
||||
|
||||
if (mesh.pos.Position.y + bounds.Y1 >= item->Pose.Position.y + itemBounds.Y2)
|
||||
if (mesh.Transform.Position.y + bounds.Y1 >= item->Pose.Position.y + itemBounds.Y2)
|
||||
return false;
|
||||
|
||||
float sinY = phd_sin(mesh.pos.Orientation.y);
|
||||
float cosY = phd_cos(mesh.pos.Orientation.y);
|
||||
float sinY = phd_sin(mesh.Transform.Orientation.y);
|
||||
float cosY = phd_cos(mesh.Transform.Orientation.y);
|
||||
|
||||
int x = item->Pose.Position.x - mesh.pos.Position.x;
|
||||
int z = item->Pose.Position.z - mesh.pos.Position.z;
|
||||
int x = item->Pose.Position.x - mesh.Transform.Position.x;
|
||||
int z = item->Pose.Position.z - mesh.Transform.Position.z;
|
||||
int dx = (x * cosY) - (z * sinY);
|
||||
int dz = (z * cosY) + (x * sinY);
|
||||
|
||||
|
@ -802,11 +802,11 @@ bool ItemPushStatic(ItemInfo* item, const MESH_INFO& mesh, CollisionInfo* coll)
|
|||
{
|
||||
const auto& bounds = GetBoundsAccurate(mesh, false);
|
||||
|
||||
float sinY = phd_sin(mesh.pos.Orientation.y);
|
||||
float cosY = phd_cos(mesh.pos.Orientation.y);
|
||||
float sinY = phd_sin(mesh.Transform.Orientation.y);
|
||||
float cosY = phd_cos(mesh.Transform.Orientation.y);
|
||||
|
||||
auto direction = item->Pose.Position - mesh.pos.Position;
|
||||
auto dz = item->Pose.Position.z - mesh.pos.Position.z;
|
||||
auto direction = item->Pose.Position - mesh.Transform.Position;
|
||||
auto dz = item->Pose.Position.z - mesh.Transform.Position.z;
|
||||
auto rx = (direction.x * cosY) - (direction.z * sinY);
|
||||
auto rz = (direction.z * cosY) + (direction.x * sinY);
|
||||
auto minX = bounds.X1 - coll->Setup.Radius;
|
||||
|
@ -835,8 +835,8 @@ bool ItemPushStatic(ItemInfo* item, const MESH_INFO& mesh, CollisionInfo* coll)
|
|||
else
|
||||
rz -= bottom;
|
||||
|
||||
item->Pose.Position.x = mesh.pos.Position.x + cosY * rx + sinY * rz;
|
||||
item->Pose.Position.z = mesh.pos.Position.z + cosY * rz - sinY * rx;
|
||||
item->Pose.Position.x = mesh.Transform.Position.x + cosY * rx + sinY * rz;
|
||||
item->Pose.Position.z = mesh.Transform.Position.z + cosY * rz - sinY * rx;
|
||||
|
||||
coll->Setup.LowerFloorBound = NO_LOWER_BOUND;
|
||||
coll->Setup.UpperFloorBound = -STEPUP_HEIGHT;
|
||||
|
@ -943,17 +943,17 @@ void CollideSolidStatics(ItemInfo* item, CollisionInfo* coll)
|
|||
for (auto& mesh : g_Level.Rooms[i].mesh)
|
||||
{
|
||||
// Only process meshes which are visible.
|
||||
if (!(mesh.flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(mesh.Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
continue;
|
||||
|
||||
// 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;
|
||||
|
||||
float distance = Vector3i::Distance(item->Pose.Position, mesh.pos.Position);
|
||||
float distance = Vector3i::Distance(item->Pose.Position, mesh.Transform.Position);
|
||||
if (distance < COLLISION_CHECK_DISTANCE)
|
||||
{
|
||||
if (CollideSolidBounds(item, GetBoundsAccurate(mesh, false), mesh.pos, coll))
|
||||
if (CollideSolidBounds(item, GetBoundsAccurate(mesh, false), mesh.Transform, coll))
|
||||
coll->HitStatic = true;
|
||||
}
|
||||
}
|
||||
|
@ -1894,15 +1894,15 @@ void DoObjectCollision(ItemInfo* item, CollisionInfo* coll)
|
|||
|
||||
for (auto& staticObject : neighborRoom.mesh)
|
||||
{
|
||||
if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(staticObject.Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
continue;
|
||||
|
||||
// For Lara, solid static mesh collisions are directly managed by GetCollisionInfo,
|
||||
// so we bypass them here to avoid interference.
|
||||
if (isPlayer && (staticObject.flags & StaticMeshFlags::SM_SOLID))
|
||||
if (isPlayer && (staticObject.Flags & StaticMeshFlags::SM_SOLID))
|
||||
continue;
|
||||
|
||||
if (Vector3i::Distance(staticObject.pos.Position, item->Pose.Position) >= COLLISION_CHECK_DISTANCE)
|
||||
if (Vector3i::Distance(staticObject.Transform.Position, item->Pose.Position) >= COLLISION_CHECK_DISTANCE)
|
||||
continue;
|
||||
|
||||
if (!TestBoundsCollideStatic(item, staticObject, coll->Setup.Radius))
|
||||
|
@ -1913,9 +1913,9 @@ void DoObjectCollision(ItemInfo* item, CollisionInfo* coll)
|
|||
// HACK: Shatter statics only by harmful vehicles.
|
||||
if (!isPlayer &&
|
||||
!isHarmless && abs(item->Animation.Velocity.z) > VEHICLE_COLLISION_TERMINAL_VELOCITY &&
|
||||
Statics[staticObject.staticNumber].shatterType != ShatterType::None)
|
||||
Statics[staticObject.ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
SoundEffect(GetShatterSound(staticObject.staticNumber), &staticObject.pos);
|
||||
SoundEffect(GetShatterSound(staticObject.ObjectId), &staticObject.Transform);
|
||||
ShatterObject(nullptr, &staticObject, -128, item->RoomNumber, 0);
|
||||
}
|
||||
else if (coll->Setup.EnableObjectPush)
|
||||
|
|
|
@ -2157,7 +2157,7 @@ void InitializeItemBoxData()
|
|||
{
|
||||
for (const auto& mesh : room.mesh)
|
||||
{
|
||||
long index = ((mesh.pos.Position.z - room.Position.z) / BLOCK(1)) + room.ZSize * ((mesh.pos.Position.x - room.Position.x) / BLOCK(1));
|
||||
long index = ((mesh.Transform.Position.z - room.Position.z) / BLOCK(1)) + room.ZSize * ((mesh.Transform.Position.x - room.Position.x) / BLOCK(1));
|
||||
if (index >= room.Sectors.size())
|
||||
continue;
|
||||
|
||||
|
@ -2167,11 +2167,11 @@ void InitializeItemBoxData()
|
|||
|
||||
if (!(g_Level.PathfindingBoxes[floor->PathfindingBoxID].flags & BLOCKED))
|
||||
{
|
||||
int floorHeight = floor->GetSurfaceHeight(mesh.pos.Position.x, mesh.pos.Position.z, true);
|
||||
int floorHeight = floor->GetSurfaceHeight(mesh.Transform.Position.x, mesh.Transform.Position.z, true);
|
||||
const auto& bBox = GetBoundsAccurate(mesh, false);
|
||||
|
||||
if (floorHeight <= mesh.pos.Position.y - bBox.Y2 + CLICK(2) &&
|
||||
floorHeight < mesh.pos.Position.y - bBox.Y1)
|
||||
if (floorHeight <= mesh.Transform.Position.y - bBox.Y2 + CLICK(2) &&
|
||||
floorHeight < mesh.Transform.Position.y - bBox.Y1)
|
||||
{
|
||||
if (bBox.X1 == 0 || bBox.X2 == 0 || bBox.Z1 == 0 || bBox.Z2 == 0 ||
|
||||
((bBox.X1 < 0) ^ (bBox.X2 < 0)) && ((bBox.Z1 < 0) ^ (bBox.Z2 < 0)))
|
||||
|
|
|
@ -413,14 +413,14 @@ void UpdateShatters()
|
|||
SmashedMeshCount--;
|
||||
|
||||
auto* floor = GetFloor(
|
||||
SmashedMesh[SmashedMeshCount]->pos.Position.x,
|
||||
SmashedMesh[SmashedMeshCount]->pos.Position.y,
|
||||
SmashedMesh[SmashedMeshCount]->pos.Position.z,
|
||||
SmashedMesh[SmashedMeshCount]->Transform.Position.x,
|
||||
SmashedMesh[SmashedMeshCount]->Transform.Position.y,
|
||||
SmashedMesh[SmashedMeshCount]->Transform.Position.z,
|
||||
&SmashedMeshRoom[SmashedMeshCount]);
|
||||
|
||||
TestTriggers(SmashedMesh[SmashedMeshCount]->pos.Position.x,
|
||||
SmashedMesh[SmashedMeshCount]->pos.Position.y,
|
||||
SmashedMesh[SmashedMeshCount]->pos.Position.z,
|
||||
TestTriggers(SmashedMesh[SmashedMeshCount]->Transform.Position.x,
|
||||
SmashedMesh[SmashedMeshCount]->Transform.Position.y,
|
||||
SmashedMesh[SmashedMeshCount]->Transform.Position.z,
|
||||
SmashedMeshRoom[SmashedMeshCount], true);
|
||||
|
||||
TestVolumes(SmashedMeshRoom[SmashedMeshCount], SmashedMesh[SmashedMeshCount]);
|
||||
|
|
|
@ -289,14 +289,14 @@ bool GetTargetOnLOS(GameVector* origin, GameVector* target, bool drawTarget, boo
|
|||
{
|
||||
if (itemNumber < 0)
|
||||
{
|
||||
if (Statics[mesh->staticNumber].shatterType != ShatterType::None)
|
||||
if (Statics[mesh->ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
const auto& weapon = Weapons[(int)Lara.Control.Weapon.GunType];
|
||||
mesh->HitPoints -= weapon.Damage;
|
||||
ShatterImpactData.impactDirection = dir;
|
||||
ShatterImpactData.impactLocation = Vector3(mesh->pos.Position.x, mesh->pos.Position.y, mesh->pos.Position.z);
|
||||
ShatterImpactData.impactLocation = Vector3(mesh->Transform.Position.x, mesh->Transform.Position.y, mesh->Transform.Position.z);
|
||||
ShatterObject(nullptr, mesh, 128, target2.RoomNumber, 0);
|
||||
SoundEffect(GetShatterSound(mesh->staticNumber), (Pose*)mesh);
|
||||
SoundEffect(GetShatterSound(mesh->ObjectId), (Pose*)mesh);
|
||||
hitProcessed = true;
|
||||
}
|
||||
|
||||
|
@ -561,12 +561,12 @@ int ObjectOnLOS2(GameVector* origin, GameVector* target, Vector3i* vec, MESH_INF
|
|||
{
|
||||
auto& meshp = room.mesh[m];
|
||||
|
||||
if (meshp.flags & StaticMeshFlags::SM_VISIBLE)
|
||||
if (meshp.Flags & StaticMeshFlags::SM_VISIBLE)
|
||||
{
|
||||
auto bounds = GetBoundsAccurate(meshp, false);
|
||||
pose = Pose(meshp.pos.Position, EulerAngles(0, meshp.pos.Orientation.y, 0));
|
||||
pose = Pose(meshp.Transform.Position, EulerAngles(0, meshp.Transform.Orientation.y, 0));
|
||||
|
||||
if (DoRayBox(*origin, *target, bounds, pose, *vec, -1 - meshp.staticNumber))
|
||||
if (DoRayBox(*origin, *target, bounds, pose, *vec, -1 - meshp.ObjectId))
|
||||
{
|
||||
*mesh = &meshp;
|
||||
target->RoomNumber = LosRooms[r];
|
||||
|
@ -702,15 +702,15 @@ std::optional<Vector3> GetStaticObjectLos(const Vector3& origin, int roomNumber,
|
|||
for (const auto& staticObject : g_Level.Rooms[neighborRoomNumber].mesh)
|
||||
{
|
||||
// Check if static is visible.
|
||||
if (!(staticObject.flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(staticObject.Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
continue;
|
||||
|
||||
// Check if static is solid (if applicable).
|
||||
if (onlySolid && !(staticObject.flags & StaticMeshFlags::SM_SOLID))
|
||||
if (onlySolid && !(staticObject.Flags & StaticMeshFlags::SM_SOLID))
|
||||
continue;
|
||||
|
||||
// Test ray-box intersection.
|
||||
auto box = GetBoundsAccurate(staticObject, false).ToBoundingOrientedBox(staticObject.pos);
|
||||
auto box = GetBoundsAccurate(staticObject, false).ToBoundingOrientedBox(staticObject.Transform);
|
||||
float intersectDist = 0.0f;
|
||||
if (box.Intersects(origin, dir, intersectDist))
|
||||
{
|
||||
|
|
|
@ -235,7 +235,7 @@ namespace TEN::Control::Volumes
|
|||
|
||||
void TestVolumes(int roomNumber, MESH_INFO* mesh)
|
||||
{
|
||||
auto box = GetBoundsAccurate(*mesh, false).ToBoundingOrientedBox(mesh->pos);
|
||||
auto box = GetBoundsAccurate(*mesh, false).ToBoundingOrientedBox(mesh->Transform);
|
||||
|
||||
TestVolumes(roomNumber, box, ActivatorFlags::Static, mesh);
|
||||
}
|
||||
|
|
|
@ -61,23 +61,23 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe
|
|||
{
|
||||
int meshIndex = 0;
|
||||
short yRot = 0;
|
||||
float scale;
|
||||
Vector3 scale;
|
||||
Vector3 pos;
|
||||
bool isStatic;
|
||||
|
||||
if (mesh)
|
||||
{
|
||||
if (!(mesh->flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(mesh->Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
return;
|
||||
|
||||
isStatic = true;
|
||||
meshIndex = Statics[mesh->staticNumber].meshNumber;
|
||||
yRot = mesh->pos.Orientation.y;
|
||||
pos = Vector3(mesh->pos.Position.x, mesh->pos.Position.y, mesh->pos.Position.z);
|
||||
scale = mesh->scale;
|
||||
meshIndex = Statics[mesh->ObjectId].meshNumber;
|
||||
yRot = mesh->Transform.Orientation.y;
|
||||
pos = Vector3(mesh->Transform.Position.x, mesh->Transform.Position.y, mesh->Transform.Position.z);
|
||||
scale = mesh->Transform.Scale;
|
||||
|
||||
if (mesh->HitPoints <= 0)
|
||||
mesh->flags &= ~StaticMeshFlags::SM_VISIBLE;
|
||||
mesh->Flags &= ~StaticMeshFlags::SM_VISIBLE;
|
||||
|
||||
SmashedMeshRoom[SmashedMeshCount] = roomNumber;
|
||||
SmashedMesh[SmashedMeshCount] = mesh;
|
||||
|
@ -89,7 +89,7 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe
|
|||
meshIndex = item->meshIndex;
|
||||
yRot = item->yRot;
|
||||
pos = item->sphere.Center;
|
||||
scale = 1.0f;
|
||||
scale = Vector3::One;
|
||||
}
|
||||
|
||||
auto fragmentsMesh = &g_Level.Meshes[meshIndex];
|
||||
|
@ -129,9 +129,9 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe
|
|||
|
||||
Matrix rotationMatrix = Matrix::CreateFromYawPitchRoll(TO_RAD(yRot), 0, 0);
|
||||
|
||||
Vector3 pos1 = fragmentsMesh->positions[poly->indices[indices[j * 3 + 0]]] * scale;
|
||||
Vector3 pos2 = fragmentsMesh->positions[poly->indices[indices[j * 3 + 1]]] * scale;
|
||||
Vector3 pos3 = fragmentsMesh->positions[poly->indices[indices[j * 3 + 2]]] * scale;
|
||||
auto pos1 = fragmentsMesh->positions[poly->indices[indices[j * 3 + 0]]] * scale;
|
||||
auto pos2 = fragmentsMesh->positions[poly->indices[indices[j * 3 + 1]]] * scale;
|
||||
auto pos3 = fragmentsMesh->positions[poly->indices[indices[j * 3 + 2]]] * scale;
|
||||
|
||||
Vector2 uv1 = poly->textureCoordinates[indices[j * 3 + 0]];
|
||||
Vector2 uv2 = poly->textureCoordinates[indices[j * 3 + 1]];
|
||||
|
@ -182,7 +182,7 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe
|
|||
fragment->velocity = CalculateFragmentImpactVelocity(fragment->worldPosition, ShatterImpactData.impactDirection, ShatterImpactData.impactLocation);
|
||||
fragment->roomNumber = roomNumber;
|
||||
fragment->numBounces = 0;
|
||||
fragment->color = isStatic ? mesh->color : item->color;
|
||||
fragment->color = isStatic ? mesh->Color : item->color;
|
||||
fragment->lightMode = fragmentsMesh->lightMode;
|
||||
|
||||
fragment->UpdateTransform();
|
||||
|
|
|
@ -903,9 +903,9 @@ void DropPickups(ItemInfo* item)
|
|||
|
||||
for (auto* staticPtr : collObjects.Statics)
|
||||
{
|
||||
auto& object = Statics[staticPtr->staticNumber];
|
||||
auto& object = Statics[staticPtr->ObjectId];
|
||||
|
||||
auto box = object.collisionBox.ToBoundingOrientedBox(staticPtr->pos);
|
||||
auto box = object.collisionBox.ToBoundingOrientedBox(staticPtr->Transform);
|
||||
if (box.Intersects(sphere))
|
||||
{
|
||||
collidedWithObject = true;
|
||||
|
@ -1003,16 +1003,16 @@ const GameBoundingBox* FindPlinth(ItemInfo* item)
|
|||
|
||||
for (int i = 0; i < room->mesh.size(); i++)
|
||||
{
|
||||
auto* mesh = &room->mesh[i];
|
||||
const auto& staticObj = room->mesh[i];
|
||||
|
||||
if (!(mesh->flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(staticObj.Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
continue;
|
||||
|
||||
if (item->Pose.Position.x != mesh->pos.Position.x || item->Pose.Position.z != mesh->pos.Position.z)
|
||||
if (item->Pose.Position.x != staticObj.Transform.Position.x || item->Pose.Position.z != staticObj.Transform.Position.z)
|
||||
continue;
|
||||
|
||||
const auto& bounds = GetBestFrame(*item).BoundingBox;
|
||||
auto& bBox = GetBoundsAccurate(*mesh, false);
|
||||
auto& bBox = GetBoundsAccurate(staticObj, false);
|
||||
|
||||
if (bounds.X1 <= bBox.X2 && bounds.X2 >= bBox.X1 &&
|
||||
bounds.Z1 <= bBox.Z2 && bounds.Z2 >= bBox.Z1 &&
|
||||
|
|
|
@ -249,22 +249,6 @@ namespace TEN::Collision::Room
|
|||
}
|
||||
}
|
||||
|
||||
GameBoundingBox& GetBoundsAccurate(const MESH_INFO& mesh, bool getVisibilityBox)
|
||||
{
|
||||
static auto bounds = GameBoundingBox();
|
||||
|
||||
if (getVisibilityBox)
|
||||
{
|
||||
bounds = Statics[mesh.staticNumber].visibilityBox * mesh.scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
bounds = Statics[mesh.staticNumber].collisionBox * mesh.scale;
|
||||
}
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
bool IsPointInRoom(const Vector3i& pos, int roomNumber)
|
||||
{
|
||||
const auto& room = g_Level.Rooms[roomNumber];
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "Game/StaticObject.h"
|
||||
#include "Math/Math.h"
|
||||
|
||||
using namespace TEN::Math;
|
||||
|
@ -35,12 +37,6 @@ enum RoomEnvFlags
|
|||
ENV_FLAG_COLD = (1 << 12)
|
||||
};
|
||||
|
||||
enum StaticMeshFlags : short
|
||||
{
|
||||
SM_VISIBLE = 1,
|
||||
SM_SOLID = 2
|
||||
};
|
||||
|
||||
struct ROOM_VERTEX
|
||||
{
|
||||
Vector3 position;
|
||||
|
@ -72,19 +68,6 @@ struct ROOM_LIGHT
|
|||
bool castShadows;
|
||||
};
|
||||
|
||||
struct MESH_INFO
|
||||
{
|
||||
Pose pos;
|
||||
int roomNumber;
|
||||
float scale;
|
||||
short staticNumber;
|
||||
short flags;
|
||||
Vector4 color;
|
||||
short HitPoints;
|
||||
std::string Name;
|
||||
bool Dirty;
|
||||
};
|
||||
|
||||
struct ROOM_INFO
|
||||
{
|
||||
int RoomNumber = 0;
|
||||
|
@ -133,7 +116,6 @@ Vector3i GetRoomCenter(int roomNumber);
|
|||
int IsRoomOutside(int x, int y, int z);
|
||||
void InitializeNeighborRoomList();
|
||||
|
||||
GameBoundingBox& GetBoundsAccurate(const MESH_INFO& mesh, bool getVisibilityBox);
|
||||
std::vector<int> GetNeighborRoomNumbers(int roomNumber, unsigned int searchDepth, std::vector<int>& visitedRoomNumbers = std::vector<int>{});
|
||||
|
||||
namespace TEN::Collision::Room
|
||||
|
|
|
@ -1021,25 +1021,23 @@ const std::vector<byte> SaveGame::Build()
|
|||
auto flybyCamerasOffset = fbb.CreateVector(flybyCameras);
|
||||
|
||||
// Static meshes and volumes
|
||||
std::vector<flatbuffers::Offset<Save::StaticMeshInfo>> staticMeshes;
|
||||
std::vector<flatbuffers::Offset<Save::Volume>> volumes;
|
||||
auto staticMeshes = std::vector<flatbuffers::Offset<Save::StaticMeshInfo>>{};
|
||||
auto volumes = std::vector<flatbuffers::Offset<Save::Volume>>{};
|
||||
for (int i = 0; i < g_Level.Rooms.size(); i++)
|
||||
{
|
||||
auto* room = &g_Level.Rooms[i];
|
||||
|
||||
for (int j = 0; j < room->mesh.size(); j++)
|
||||
{
|
||||
Save::StaticMeshInfoBuilder staticMesh{ fbb };
|
||||
auto staticObjBuilder = Save::StaticMeshInfoBuilder(fbb);
|
||||
|
||||
staticMesh.add_pose(&FromPose(room->mesh[j].pos));
|
||||
staticMesh.add_scale(room->mesh[j].scale);
|
||||
staticMesh.add_color(&FromVector4(room->mesh[j].color));
|
||||
|
||||
staticMesh.add_flags(room->mesh[j].flags);
|
||||
staticMesh.add_hit_points(room->mesh[j].HitPoints);
|
||||
staticMesh.add_room_number(room->RoomNumber);
|
||||
staticMesh.add_number(j);
|
||||
staticMeshes.push_back(staticMesh.Finish());
|
||||
staticObjBuilder.add_id(j);
|
||||
staticObjBuilder.add_transform(&FromPose(room->mesh[j].Transform));
|
||||
staticObjBuilder.add_room_number(room->RoomNumber);
|
||||
staticObjBuilder.add_color(&FromVector4(room->mesh[j].Color));
|
||||
staticObjBuilder.add_hit_points(room->mesh[j].HitPoints);
|
||||
staticObjBuilder.add_flags(room->mesh[j].Flags);
|
||||
staticMeshes.push_back(staticObjBuilder.Finish());
|
||||
}
|
||||
|
||||
for (int j = 0; j < room->TriggerVolumes.size(); j++)
|
||||
|
@ -2303,29 +2301,29 @@ static void ParseLevel(const Save::SaveGame* s, bool hubMode)
|
|||
g_Level.Rooms[room->index()].reverbType = (ReverbType)room->reverb_type();
|
||||
}
|
||||
|
||||
// Static objects.
|
||||
// Static objects
|
||||
for (int i = 0; i < s->static_meshes()->size(); i++)
|
||||
{
|
||||
auto staticMesh = s->static_meshes()->Get(i);
|
||||
auto room = &g_Level.Rooms[staticMesh->room_number()];
|
||||
int number = staticMesh->number();
|
||||
const auto& savedStaticObj = *s->static_meshes()->Get(i);
|
||||
auto& room = g_Level.Rooms[savedStaticObj.room_number()];
|
||||
|
||||
room->mesh[number].pos = ToPose(*staticMesh->pose());
|
||||
room->mesh[number].roomNumber = staticMesh->room_number();
|
||||
room->mesh[number].scale = staticMesh->scale();
|
||||
room->mesh[number].color = ToVector4(staticMesh->color());
|
||||
int staticId = savedStaticObj.id();
|
||||
auto& staticObj = room.mesh[staticId];
|
||||
|
||||
room->mesh[number].flags = staticMesh->flags();
|
||||
room->mesh[number].HitPoints = staticMesh->hit_points();
|
||||
|
||||
room->mesh[number].Dirty = true;
|
||||
staticObj.Transform = ToPose(*savedStaticObj.transform());
|
||||
staticObj.RoomNumber = savedStaticObj.room_number();
|
||||
staticObj.Color = ToVector4(savedStaticObj.color());
|
||||
staticObj.HitPoints = savedStaticObj.hit_points();
|
||||
staticObj.Flags = savedStaticObj.flags();
|
||||
staticObj.Dirty = true;
|
||||
|
||||
if (!room->mesh[number].flags)
|
||||
if (!staticObj.Flags)
|
||||
{
|
||||
short roomNumber = staticMesh->room_number();
|
||||
FloorInfo* floor = GetFloor(room->mesh[number].pos.Position.x, room->mesh[number].pos.Position.y, room->mesh[number].pos.Position.z, &roomNumber);
|
||||
TestTriggers(room->mesh[number].pos.Position.x, room->mesh[number].pos.Position.y, room->mesh[number].pos.Position.z, staticMesh->room_number(), true, 0);
|
||||
floor->Stopper = false;
|
||||
int roomNumber = savedStaticObj.room_number();
|
||||
auto& sector = *GetFloor(staticObj.Transform.Position.x, staticObj.Transform.Position.y, staticObj.Transform.Position.z, (short*)&roomNumber);
|
||||
|
||||
TestTriggers(staticObj.Transform.Position.x, staticObj.Transform.Position.y, staticObj.Transform.Position.z, savedStaticObj.room_number(), true, 0);
|
||||
sector.Stopper = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -192,9 +192,9 @@ namespace TEN::Entities::TR4
|
|||
{
|
||||
for (auto& mesh : room.mesh)
|
||||
{
|
||||
if (abs(pos.x - mesh.pos.Position.x) < BLOCK(1) &&
|
||||
abs(pos.z - mesh.pos.Position.z) < BLOCK(1) &&
|
||||
Statics[mesh.staticNumber].shatterType == ShatterType::None)
|
||||
if (abs(pos.x - mesh.Transform.Position.x) < BLOCK(1) &&
|
||||
abs(pos.z - mesh.Transform.Position.z) < BLOCK(1) &&
|
||||
Statics[mesh.ObjectId].shatterType == ShatterType::None)
|
||||
{
|
||||
ShatterObject(nullptr, &mesh, -64, LaraItem->RoomNumber, 0);
|
||||
SoundEffect(SFX_TR4_SMASH_ROCK, &item->Pose);
|
||||
|
|
|
@ -650,9 +650,9 @@ namespace TEN::Entities::TR4
|
|||
{
|
||||
auto* staticMesh = &room->mesh[i];
|
||||
|
||||
if (abs(pos.x - staticMesh->pos.Position.x) < BLOCK(1) &&
|
||||
abs(pos.z - staticMesh->pos.Position.z) < BLOCK(1) &&
|
||||
Statics[staticMesh->staticNumber].shatterType != ShatterType::None)
|
||||
if (abs(pos.x - staticMesh->Transform.Position.x) < BLOCK(1) &&
|
||||
abs(pos.z - staticMesh->Transform.Position.z) < BLOCK(1) &&
|
||||
Statics[staticMesh->ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
ShatterObject(0, staticMesh, -128, LaraItem->RoomNumber, 0);
|
||||
SoundEffect(SFX_TR4_SMASH_ROCK, &item->Pose);
|
||||
|
|
|
@ -93,9 +93,9 @@ namespace TEN::Entities::TR4
|
|||
{
|
||||
auto* mesh = &room->mesh[i];
|
||||
|
||||
if (((mesh->pos.Position.z / BLOCK(1)) == (z / BLOCK(1))) &&
|
||||
((mesh->pos.Position.x / BLOCK(1)) == (x / BLOCK(1))) &&
|
||||
Statics[mesh->staticNumber].shatterType != ShatterType::None)
|
||||
if (((mesh->Transform.Position.z / BLOCK(1)) == (z / BLOCK(1))) &&
|
||||
((mesh->Transform.Position.x / BLOCK(1)) == (x / BLOCK(1))) &&
|
||||
Statics[mesh->ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
ShatterObject(nullptr, mesh, -64, item->RoomNumber, 0);
|
||||
SoundEffect(SFX_TR4_SMASH_ROCK, &item->Pose);
|
||||
|
|
|
@ -85,19 +85,19 @@ namespace TEN::Entities::Traps
|
|||
pointColl1.GetSector().Stopper)
|
||||
{
|
||||
auto& room = g_Level.Rooms[item.RoomNumber];
|
||||
for (auto& mesh : room.mesh)
|
||||
for (auto& staticObj : room.mesh)
|
||||
{
|
||||
if ((abs(pointColl0.GetPosition().x - mesh.pos.Position.x) < BLOCK(1) &&
|
||||
abs(pointColl0.GetPosition().z - mesh.pos.Position.z) < BLOCK(1)) ||
|
||||
abs(pointColl1.GetPosition().x - mesh.pos.Position.x) < BLOCK(1) &&
|
||||
abs(pointColl1.GetPosition().z - mesh.pos.Position.z) < BLOCK(1) &&
|
||||
Statics[mesh.staticNumber].shatterType != ShatterType::None)
|
||||
if ((abs(pointColl0.GetPosition().x - staticObj.Transform.Position.x) < BLOCK(1) &&
|
||||
abs(pointColl0.GetPosition().z - staticObj.Transform.Position.z) < BLOCK(1)) ||
|
||||
abs(pointColl1.GetPosition().x - staticObj.Transform.Position.x) < BLOCK(1) &&
|
||||
abs(pointColl1.GetPosition().z - staticObj.Transform.Position.z) < BLOCK(1) &&
|
||||
Statics[staticObj.ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
if (mesh.HitPoints != 0)
|
||||
if (staticObj.HitPoints != 0)
|
||||
continue;
|
||||
|
||||
mesh.HitPoints -= 1;
|
||||
ShatterObject(nullptr, &mesh, -64, LaraItem->RoomNumber, 0);
|
||||
staticObj.HitPoints--;
|
||||
ShatterObject(nullptr, &staticObj, -64, LaraItem->RoomNumber, 0);
|
||||
SoundEffect(SFX_TR4_SMASH_ROCK, &item.Pose);
|
||||
TestTriggers(item.Pose.Position.x, item.Pose.Position.y, item.Pose.Position.z, item.RoomNumber, true);
|
||||
}
|
||||
|
|
|
@ -344,11 +344,11 @@ namespace TEN::Entities::Creatures::TR5
|
|||
{
|
||||
auto* mesh = &room->mesh[i];
|
||||
|
||||
if (!((pos.z ^ mesh->pos.Position.z) & 0xFFFFFC00))
|
||||
if (!((pos.z ^ mesh->Transform.Position.z) & 0xFFFFFC00))
|
||||
{
|
||||
if (!((pos.x ^ mesh->pos.Position.x) & 0xFFFFFC00))
|
||||
if (!((pos.x ^ mesh->Transform.Position.x) & 0xFFFFFC00))
|
||||
{
|
||||
if (Statics[mesh->staticNumber].shatterType != ShatterType::None)
|
||||
if (Statics[mesh->ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
ShatterObject(0, mesh, -64, LaraItem->RoomNumber, 0);
|
||||
//SoundEffect(ShatterSounds[gfCurrentLevel - 5][*(v28 + 18)], v28);
|
||||
|
|
|
@ -109,11 +109,11 @@ namespace TEN::Entities::Creatures::TR5
|
|||
|
||||
if (objOnLos < 0 && GetRandomControl() & 1)
|
||||
{
|
||||
if (Statics[hitMesh->staticNumber].shatterType != ShatterType::None)
|
||||
if (Statics[hitMesh->ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
ShatterObject(0, hitMesh, 64, target.RoomNumber, 0);
|
||||
TestTriggers(hitMesh->pos.Position.x, hitMesh->pos.Position.y, hitMesh->pos.Position.z, target.RoomNumber, true);
|
||||
SoundEffect(GetShatterSound(hitMesh->staticNumber), &hitMesh->pos);
|
||||
TestTriggers(hitMesh->Transform.Position.x, hitMesh->Transform.Position.y, hitMesh->Transform.Position.z, target.RoomNumber, true);
|
||||
SoundEffect(GetShatterSound(hitMesh->ObjectId), &hitMesh->Transform);
|
||||
}
|
||||
|
||||
TriggerRicochetSpark(GameVector(hitPos), 2 * GetRandomControl());
|
||||
|
|
|
@ -556,12 +556,12 @@ namespace TEN::Entities::Creatures::TR5
|
|||
{
|
||||
auto* mesh = &room->mesh[i];
|
||||
|
||||
if (!((mesh->pos.Position.z ^ pos.z) & 0xFFFFFC00) && !((mesh->pos.Position.x ^ pos.x) & 0xFFFFFC00))
|
||||
if (!((mesh->Transform.Position.z ^ pos.z) & 0xFFFFFC00) && !((mesh->Transform.Position.x ^ pos.x) & 0xFFFFFC00))
|
||||
{
|
||||
if (Statics[mesh->staticNumber].shatterType != ShatterType::None)
|
||||
if (Statics[mesh->ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
ShatterObject(0, mesh, -64, LaraItem->RoomNumber, 0);
|
||||
SoundEffect(GetShatterSound(mesh->staticNumber), (Pose*)mesh);
|
||||
SoundEffect(GetShatterSound(mesh->ObjectId), (Pose*)mesh);
|
||||
|
||||
floor->Stopper = false;
|
||||
|
||||
|
|
|
@ -163,13 +163,13 @@ namespace TEN::Entities::Traps
|
|||
|
||||
for (auto* staticPtr : collObjects.Statics)
|
||||
{
|
||||
if (Statics[staticPtr->staticNumber].shatterType != ShatterType::None)
|
||||
if (Statics[staticPtr->ObjectId].shatterType != ShatterType::None)
|
||||
{
|
||||
TriggerExplosionSparks(staticPtr->pos.Position.x, staticPtr->pos.Position.y, staticPtr->pos.Position.z, 3, -2, 0, item.RoomNumber);
|
||||
staticPtr->pos.Position.y -= 128;
|
||||
TriggerShockwave(&staticPtr->pos, 40, 176, 64, 128, 96, 0, 16, EulerAngles::Identity, 0, true, false, false, (int)ShockwaveStyle::Normal);
|
||||
staticPtr->pos.Position.y += 128;
|
||||
SoundEffect(GetShatterSound(staticPtr->staticNumber), &staticPtr->pos);
|
||||
TriggerExplosionSparks(staticPtr->Transform.Position.x, staticPtr->Transform.Position.y, staticPtr->Transform.Position.z, 3, -2, 0, item.RoomNumber);
|
||||
staticPtr->Transform.Position.y -= 128;
|
||||
TriggerShockwave(&staticPtr->Transform, 40, 176, 64, 128, 96, 0, 16, EulerAngles::Identity, 0, true, false, false, (int)ShockwaveStyle::Normal);
|
||||
staticPtr->Transform.Position.y += 128;
|
||||
SoundEffect(GetShatterSound(staticPtr->ObjectId), &staticPtr->Transform);
|
||||
ShatterObject(nullptr, staticPtr, -128, item.RoomNumber, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ namespace TEN::Renderer
|
|||
void CollectMirrors(RenderView& renderView);
|
||||
void CollectRooms(RenderView& renderView, bool onlyRooms);
|
||||
void CollectItems(short roomNumber, RenderView& renderView);
|
||||
void CollectStatics(short roomNumber, RenderView& renderView);
|
||||
void CollectStatics(int roomNumber, RenderView& renderView);
|
||||
void CollectLights(const Vector3& pos, float radius, int roomNumber, int prevRoomNumber, bool prioritizeShadowLight, bool useCachedRoomLights, std::vector<RendererLightNode>* roomsLights, std::vector<RendererLight*>* outputLights);
|
||||
void CollectLightsForItem(RendererItem* item);
|
||||
void CollectLightsForEffect(short roomNumber, RendererEffect* effect);
|
||||
|
|
|
@ -267,21 +267,19 @@ namespace TEN::Renderer
|
|||
|
||||
for (int l = 0; l < (int)room.mesh.size(); l++)
|
||||
{
|
||||
RendererStatic* staticInfo = &r->Statics[l];
|
||||
MESH_INFO* oldMesh = &room.mesh[l];
|
||||
auto& rendererStatic = r->Statics[l];
|
||||
auto& nativeStatic = room.mesh[l];
|
||||
|
||||
oldMesh->Dirty = true;
|
||||
rendererStatic.ObjectNumber = nativeStatic.ObjectId;
|
||||
rendererStatic.RoomNumber = nativeStatic.RoomNumber;
|
||||
rendererStatic.Color = nativeStatic.Color;
|
||||
rendererStatic.AmbientLight = r->AmbientLight;
|
||||
rendererStatic.Pose = nativeStatic.Transform;
|
||||
rendererStatic.OriginalSphere = Statics[rendererStatic.ObjectNumber].visibilityBox.ToLocalBoundingSphere();
|
||||
rendererStatic.IndexInRoom = l;
|
||||
|
||||
staticInfo->ObjectNumber = oldMesh->staticNumber;
|
||||
staticInfo->RoomNumber = oldMesh->roomNumber;
|
||||
staticInfo->Color = oldMesh->color;
|
||||
staticInfo->AmbientLight = r->AmbientLight;
|
||||
staticInfo->Pose = oldMesh->pos;
|
||||
staticInfo->Scale = oldMesh->scale;
|
||||
staticInfo->OriginalSphere = Statics[staticInfo->ObjectNumber].visibilityBox.ToLocalBoundingSphere();
|
||||
staticInfo->IndexInRoom = l;
|
||||
|
||||
staticInfo->Update();
|
||||
nativeStatic.Dirty = true;
|
||||
rendererStatic.Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -484,79 +484,76 @@ namespace TEN::Renderer
|
|||
}
|
||||
}
|
||||
|
||||
void Renderer::CollectStatics(short roomNumber, RenderView& renderView)
|
||||
void Renderer::CollectStatics(int roomNumber, RenderView& renderView)
|
||||
{
|
||||
if (_rooms.size() <= roomNumber)
|
||||
return;
|
||||
|
||||
auto& room = _rooms[roomNumber];
|
||||
auto* r = &g_Level.Rooms[room.RoomNumber];
|
||||
auto& rendererRoom = _rooms[roomNumber];
|
||||
auto& nativeRoom = g_Level.Rooms[rendererRoom.RoomNumber];
|
||||
|
||||
if (r->mesh.empty())
|
||||
if (nativeRoom.mesh.empty())
|
||||
return;
|
||||
|
||||
bool isRoomReflected = IsRoomReflected(renderView, roomNumber);
|
||||
|
||||
for (int i = 0; i < room.Statics.size(); i++)
|
||||
for (int i = 0; i < rendererRoom.Statics.size(); i++)
|
||||
{
|
||||
auto* mesh = &room.Statics[i];
|
||||
auto* nativeMesh = &r->mesh[i];
|
||||
auto& rendererStatic = rendererRoom.Statics[i];
|
||||
auto& nativeStatic = nativeRoom.mesh[i];
|
||||
|
||||
if (nativeMesh->Dirty || _invalidateCache)
|
||||
if (nativeStatic.Dirty || _invalidateCache)
|
||||
{
|
||||
mesh->ObjectNumber = nativeMesh->staticNumber;
|
||||
mesh->Color = nativeMesh->color;
|
||||
mesh->OriginalSphere = Statics[mesh->ObjectNumber].visibilityBox.ToLocalBoundingSphere();
|
||||
mesh->Pose = nativeMesh->pos;
|
||||
mesh->Scale = nativeMesh->scale;
|
||||
mesh->Update();
|
||||
rendererStatic.ObjectNumber = nativeStatic.ObjectId;
|
||||
rendererStatic.Color = nativeStatic.Color;
|
||||
rendererStatic.OriginalSphere = Statics[rendererStatic.ObjectNumber].visibilityBox.ToLocalBoundingSphere();
|
||||
rendererStatic.Pose = nativeStatic.Transform;
|
||||
rendererStatic.Update();
|
||||
|
||||
nativeMesh->Dirty = false;
|
||||
nativeStatic.Dirty = false;
|
||||
}
|
||||
|
||||
if (!(nativeMesh->flags & StaticMeshFlags::SM_VISIBLE))
|
||||
if (!(nativeStatic.Flags & StaticMeshFlags::SM_VISIBLE))
|
||||
continue;
|
||||
|
||||
if (!_staticObjects[Statics.GetIndex(mesh->ObjectNumber)].has_value())
|
||||
if (!_staticObjects[Statics.GetIndex(rendererStatic.ObjectNumber)].has_value())
|
||||
continue;
|
||||
|
||||
auto& obj = GetStaticRendererObject(mesh->ObjectNumber);
|
||||
|
||||
if (obj.ObjectMeshes.empty())
|
||||
const auto& rendererObj = GetStaticRendererObject(rendererStatic.ObjectNumber);
|
||||
if (rendererObj.ObjectMeshes.empty())
|
||||
continue;
|
||||
|
||||
if (!isRoomReflected && !renderView.Camera.Frustum.SphereInFrustum(mesh->Sphere.Center, mesh->Sphere.Radius))
|
||||
if (!isRoomReflected && !renderView.Camera.Frustum.SphereInFrustum(rendererStatic.Sphere.Center, rendererStatic.Sphere.Radius))
|
||||
continue;
|
||||
|
||||
// Collect the lights
|
||||
std::vector<RendererLight*> lights;
|
||||
std::vector<RendererLightNode> cachedRoomLights;
|
||||
if (obj.ObjectMeshes.front()->LightMode != LightMode::Static)
|
||||
// Collect lights;
|
||||
auto lights = std::vector<RendererLight*>{};
|
||||
auto cachedRoomLights = std::vector<RendererLightNode>{};
|
||||
if (rendererObj.ObjectMeshes.front()->LightMode != LightMode::Static)
|
||||
{
|
||||
if (mesh->CacheLights || _invalidateCache)
|
||||
if (rendererStatic.CacheLights || _invalidateCache)
|
||||
{
|
||||
// Collect all lights and return also cached light for the next frames
|
||||
CollectLights(mesh->Pose.Position.ToVector3(),1024, room.RoomNumber, NO_VALUE, false, false, &cachedRoomLights, &lights);
|
||||
mesh->CacheLights = false;
|
||||
mesh->CachedRoomLights = cachedRoomLights;
|
||||
// Collect all lights and return cached light for next frames.
|
||||
CollectLights(rendererStatic.Pose.Position.ToVector3(),1024, rendererRoom.RoomNumber, NO_VALUE, false, false, &cachedRoomLights, &lights);
|
||||
rendererStatic.CacheLights = false;
|
||||
rendererStatic.CachedRoomLights = cachedRoomLights;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Collect only dynamic lights and use cached lights from rooms
|
||||
CollectLights(mesh->Pose.Position.ToVector3(), 1024, room.RoomNumber, NO_VALUE, false, true, &mesh->CachedRoomLights, &lights);
|
||||
// Collect only dynamic lights and use cached lights from rooms.
|
||||
CollectLights(rendererStatic.Pose.Position.ToVector3(), 1024, rendererRoom.RoomNumber, NO_VALUE, false, true, &rendererStatic.CachedRoomLights, &lights);
|
||||
}
|
||||
}
|
||||
mesh->LightsToDraw = lights;
|
||||
rendererStatic.LightsToDraw = lights;
|
||||
|
||||
// At this point, we are sure that we must draw the static mesh
|
||||
room.StaticsToDraw.push_back(mesh);
|
||||
rendererRoom.StaticsToDraw.push_back(&rendererStatic);
|
||||
|
||||
if (renderView.SortedStaticsToDraw.find(mesh->ObjectNumber) == renderView.SortedStaticsToDraw.end())
|
||||
if (renderView.SortedStaticsToDraw.find(rendererStatic.ObjectNumber) == renderView.SortedStaticsToDraw.end())
|
||||
{
|
||||
std::vector<RendererStatic*> vec;
|
||||
renderView.SortedStaticsToDraw.insert(std::pair<int, std::vector<RendererStatic*>>(mesh->ObjectNumber, std::vector<RendererStatic*>()));
|
||||
auto rendererStatics = std::vector<RendererStatic*>{};
|
||||
renderView.SortedStaticsToDraw.insert(std::pair<int, std::vector<RendererStatic*>>(rendererStatic.ObjectNumber, std::vector<RendererStatic*>()));
|
||||
}
|
||||
renderView.SortedStaticsToDraw[mesh->ObjectNumber].push_back(mesh);
|
||||
renderView.SortedStaticsToDraw[rendererStatic.ObjectNumber].push_back(&rendererStatic);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,42 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <SimpleMath.h>
|
||||
|
||||
#include "Math/Objects/GameBoundingBox.h"
|
||||
#include "Math/Objects/Pose.h"
|
||||
#include "Renderer/Structures/RendererLight.h"
|
||||
|
||||
namespace TEN::Renderer::Structures
|
||||
{
|
||||
using namespace DirectX;
|
||||
using namespace DirectX::SimpleMath;
|
||||
|
||||
struct RendererStatic
|
||||
{
|
||||
int ObjectNumber;
|
||||
int RoomNumber;
|
||||
int IndexInRoom;
|
||||
Pose Pose;
|
||||
Matrix World;
|
||||
|
||||
Pose Pose;
|
||||
Matrix World;
|
||||
Vector4 Color;
|
||||
Vector4 AmbientLight;
|
||||
std::vector<RendererLight*> LightsToDraw;
|
||||
|
||||
std::vector<RendererLight*> LightsToDraw;
|
||||
std::vector<RendererLightNode> CachedRoomLights;
|
||||
bool CacheLights;
|
||||
bool CacheLights;
|
||||
|
||||
BoundingSphere OriginalSphere;
|
||||
BoundingSphere Sphere;
|
||||
float Scale;
|
||||
|
||||
void Update()
|
||||
{
|
||||
World = (Pose.Orientation.ToRotationMatrix() *
|
||||
Matrix::CreateScale(Scale) *
|
||||
Matrix::CreateTranslation(Pose.Position.x, Pose.Position.y, Pose.Position.z));
|
||||
Sphere = BoundingSphere(Vector3::Transform(OriginalSphere.Center, World), OriginalSphere.Radius * Scale);
|
||||
auto translationMatrix = Matrix::CreateTranslation(Pose.Position.ToVector3());
|
||||
auto rotMatrix = Pose.Orientation.ToRotationMatrix();
|
||||
auto scaleMatrix = Matrix::CreateScale(Pose.Scale);
|
||||
auto worldMatrix = rotMatrix * scaleMatrix * translationMatrix;
|
||||
|
||||
auto sphereCenter = Vector3::Transform(OriginalSphere.Center, World);
|
||||
float sphereScale = std::max({ Pose.Scale.x, Pose.Scale.y, Pose.Scale.z });
|
||||
float sphereRadius = OriginalSphere.Radius * sphereScale;
|
||||
|
||||
World = worldMatrix;
|
||||
Sphere = BoundingSphere(sphereCenter, sphereRadius);
|
||||
CacheLights = true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -431,20 +431,20 @@ constexpr char ScriptReserved_StaticDisable[] = "Disable";
|
|||
constexpr char ScriptReserved_StaticEnable[] = "Enable";
|
||||
constexpr char ScriptReserved_StaticGetActive[] = "GetActive";
|
||||
constexpr char ScriptReserved_StaticGetColor[] = "GetColor";
|
||||
constexpr char ScriptReserved_StaticGetHP[] = "GetHP";
|
||||
constexpr char ScriptReserved_StaticGetHitPoints[] = "GetHitPoints";
|
||||
constexpr char ScriptReserved_StaticGetName[] = "GetName";
|
||||
constexpr char ScriptReserved_StaticGetObjectId[] = "GetObjectID";
|
||||
constexpr char ScriptReserved_StaticGetPosition[] = "GetPosition";
|
||||
constexpr char ScriptReserved_StaticGetRotation[] = "GetRotation";
|
||||
constexpr char ScriptReserved_StaticGetScale[] = "GetScale";
|
||||
constexpr char ScriptReserved_StaticGetSlot[] = "GetSlot";
|
||||
constexpr char ScriptReserved_StaticGetSolid[] = "GetSolid";
|
||||
constexpr char ScriptReserved_StaticSetColor[] = "SetColor";
|
||||
constexpr char ScriptReserved_StaticSetHitPoints[] = "SetHP";
|
||||
constexpr char ScriptReserved_StaticSetHitPoints[] = "SetHitPoints";
|
||||
constexpr char ScriptReserved_StaticSetName[] = "SetName";
|
||||
constexpr char ScriptReserved_StaticSetObjectId[] = "SetObjectID";
|
||||
constexpr char ScriptReserved_StaticSetPosition[] = "SetPosition";
|
||||
constexpr char ScriptReserved_StaticSetRotation[] = "SetRotation";
|
||||
constexpr char ScriptReserved_StaticSetScale[] = "SetScale";
|
||||
constexpr char ScriptReserved_StaticSetSlot[] = "SetSlot";
|
||||
constexpr char ScriptReserved_StaticSetSolid[] = "SetSolid";
|
||||
constexpr char ScriptReserved_StaticShatter[] = "Shatter";
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ private:
|
|||
|
||||
auto staticObj = std::get<std::reference_wrapper<MESH_INFO>>(value).get();
|
||||
|
||||
if (staticObj.staticNumber == slot)
|
||||
if (staticObj.ObjectId == slot)
|
||||
items.push_back(GetByName<Static, ScriptReserved_Static>(key));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "framework.h"
|
||||
|
||||
#include "Game/effects/debris.h"
|
||||
#include "Objects/game_object_ids.h"
|
||||
#include "Scripting/Internal/ReservedScriptNames.h"
|
||||
#include "Scripting/Internal/ScriptUtil.h"
|
||||
#include "Scripting/Internal/ScriptAssert.h"
|
||||
|
@ -30,28 +31,39 @@ namespace TEN::Scripting
|
|||
sol::meta_function::index, IndexError,
|
||||
sol::meta_function::new_index, NewIndexError,
|
||||
|
||||
// Getters
|
||||
ScriptReserved_StaticGetName, &Static::GetName,
|
||||
ScriptReserved_StaticGetSlot, &Static::GetSlot,
|
||||
ScriptReserved_StaticGetObjectId, &Static::GetObjectId,
|
||||
ScriptReserved_StaticGetPosition, &Static::GetPosition,
|
||||
ScriptReserved_StaticGetRotation, &Static::GetRotation,
|
||||
ScriptReserved_StaticGetScale, &Static::GetScale, // TODO: Deprecate. Should return Vec3 converted from static.Pose.Scale.
|
||||
ScriptReserved_StaticGetScale, &Static::GetScale,
|
||||
ScriptReserved_StaticGetColor, &Static::GetColor,
|
||||
ScriptReserved_StaticGetHP, &Static::GetHitPoints, // TODO: Deprecate.
|
||||
ScriptReserved_StaticGetHitPoints, &Static::GetHitPoints,
|
||||
ScriptReserved_StaticGetActive, &Static::GetActiveStatus, // TODO: Deprecate. Rename Lua func to GetActiveStatus.
|
||||
ScriptReserved_StaticGetSolid, &Static::GetSolidStatus, // TODO: Deprecate. Rename Lua func to GetSolidStatus.
|
||||
|
||||
// Setters
|
||||
ScriptReserved_StaticSetName, &Static::SetName,
|
||||
ScriptReserved_StaticSetSlot, &Static::SetSlot,
|
||||
ScriptReserved_StaticSetObjectId, &Static::SetObjectId,
|
||||
ScriptReserved_StaticSetPosition, &Static::SetPosition,
|
||||
ScriptReserved_StaticSetRotation, &Static::SetRotation,
|
||||
ScriptReserved_StaticSetScale, &Static::SetScale,
|
||||
ScriptReserved_StaticSetScale, sol::overload(
|
||||
(void(Static::*)(const Vec3&))(&Static::SetScale),
|
||||
(void(Static::*)(float))(&Static::SetScale)), // COMPATIBILITY
|
||||
ScriptReserved_StaticSetColor, &Static::SetColor,
|
||||
ScriptReserved_StaticSetHitPoints, &Static::SetHitPoints, // TODO: Deprecate. Rename Lua func to SetHitPoints.
|
||||
ScriptReserved_StaticSetHitPoints, &Static::SetHitPoints,
|
||||
ScriptReserved_StaticSetSolid, &Static::SetSolidStatus, // TODO: Deprecate. Rename Lua func to SetSolidStatus.
|
||||
|
||||
// Utilities
|
||||
ScriptReserved_StaticEnable, &Static::Enable,
|
||||
ScriptReserved_StaticDisable, &Static::Disable,
|
||||
ScriptReserved_StaticShatter, &Static::Shatter);
|
||||
ScriptReserved_StaticShatter, &Static::Shatter,
|
||||
|
||||
// COMPATIBILITY
|
||||
"GetSlot", &Static::GetObjectId,
|
||||
"GetHP", &Static::GetHitPoints,
|
||||
"SetSlot", &Static::SetObjectId,
|
||||
"SetHP", &Static::SetHitPoints);
|
||||
}
|
||||
|
||||
Static::Static(MESH_INFO& staticObj) :
|
||||
|
@ -67,12 +79,12 @@ namespace TEN::Scripting
|
|||
return _static.Name;
|
||||
}
|
||||
|
||||
/// Get this static's slot ID.
|
||||
// @function Static:GetSlot
|
||||
// @treturn int Slot ID.
|
||||
int Static::GetSlot() const
|
||||
/// Get this static's object ID.
|
||||
// @function Static:GetObjectID
|
||||
// @treturn Objects.ObjID Object ID.
|
||||
GAME_OBJECT_ID Static::GetObjectId() const
|
||||
{
|
||||
return _static.staticNumber;
|
||||
return _static.ObjectId;
|
||||
}
|
||||
|
||||
/// Get this static's world position.
|
||||
|
@ -80,7 +92,7 @@ namespace TEN::Scripting
|
|||
// @treturn Vec3 World position.
|
||||
Vec3 Static::GetPosition() const
|
||||
{
|
||||
return Vec3(_static.pos.Position);
|
||||
return Vec3(_static.Transform.Position);
|
||||
}
|
||||
|
||||
/// Get this static's world rotation.
|
||||
|
@ -88,15 +100,15 @@ namespace TEN::Scripting
|
|||
// @treturn Rotation World rotation.
|
||||
Rotation Static::GetRotation() const
|
||||
{
|
||||
return Rotation(_static.pos.Orientation);
|
||||
return Rotation(_static.Transform.Orientation);
|
||||
}
|
||||
|
||||
/// Get this static's world scale.
|
||||
// @function Static:GetScale
|
||||
// @treturn float World scale.
|
||||
float Static::GetScale() const
|
||||
// @treturn Vec3 World scale.
|
||||
Vec3 Static::GetScale() const
|
||||
{
|
||||
return _static.scale;
|
||||
return Vec3(_static.Transform.Scale);
|
||||
}
|
||||
|
||||
/// Get this static's color.
|
||||
|
@ -104,11 +116,11 @@ namespace TEN::Scripting
|
|||
// @treturn Color Color.
|
||||
ScriptColor Static::GetColor() const
|
||||
{
|
||||
return ScriptColor(_static.color);
|
||||
return ScriptColor(_static.Color);
|
||||
}
|
||||
|
||||
/// Get this static's hit points. Used only with shatterable statics.
|
||||
// @function Static:GetHP
|
||||
// @function Static:GetHitPoints
|
||||
// @treturn int Hit points.
|
||||
int Static::GetHitPoints() const
|
||||
{
|
||||
|
@ -120,7 +132,7 @@ namespace TEN::Scripting
|
|||
// @treturn bool Status. __true: visible__, __false: invisible__
|
||||
bool Static::GetActiveStatus() const
|
||||
{
|
||||
return ((_static.flags & StaticMeshFlags::SM_VISIBLE) != 0);
|
||||
return ((_static.Flags & StaticMeshFlags::SM_VISIBLE) != 0);
|
||||
}
|
||||
|
||||
/// Get this static's solid collision status.
|
||||
|
@ -128,7 +140,7 @@ namespace TEN::Scripting
|
|||
// @treturn bool Solid Status. __true: solid__, __false: soft__
|
||||
bool Static::GetSolidStatus() const
|
||||
{
|
||||
return ((_static.flags & StaticMeshFlags::SM_SOLID) != 0);
|
||||
return ((_static.Flags & StaticMeshFlags::SM_SOLID) != 0);
|
||||
}
|
||||
|
||||
/// Set this static's unique identifier string.
|
||||
|
@ -151,12 +163,12 @@ namespace TEN::Scripting
|
|||
}
|
||||
}
|
||||
|
||||
/// Set this static's slot ID.
|
||||
// @function Static:SetSlot
|
||||
// @tparam int slotID New slot ID.
|
||||
void Static::SetSlot(int slotID)
|
||||
/// Set this static's object ID.
|
||||
// @function Static:SetObjectID
|
||||
// @tparam Objects.ObjID slotID New object ID.
|
||||
void Static::SetObjectId(GAME_OBJECT_ID objectId)
|
||||
{
|
||||
_static.staticNumber = slotID;
|
||||
_static.ObjectId = objectId;
|
||||
_static.Dirty = true;
|
||||
}
|
||||
|
||||
|
@ -165,7 +177,7 @@ namespace TEN::Scripting
|
|||
// @tparam Vec3 pos New world position.
|
||||
void Static::SetPosition(const Vec3& pos)
|
||||
{
|
||||
_static.pos.Position = pos.ToVector3i();
|
||||
_static.Transform.Position = pos.ToVector3i();
|
||||
_static.Dirty = true;
|
||||
}
|
||||
|
||||
|
@ -174,16 +186,16 @@ namespace TEN::Scripting
|
|||
// @tparam Rotation rot New rotation.
|
||||
void Static::SetRotation(const Rotation& rot)
|
||||
{
|
||||
_static.pos.Orientation = rot.ToEulerAngles();
|
||||
_static.Transform.Orientation = rot.ToEulerAngles();
|
||||
_static.Dirty = true;
|
||||
}
|
||||
|
||||
/// Set this static's world scale.
|
||||
// @function Static:SetScale
|
||||
// @tparam float scale New world scale.
|
||||
void Static::SetScale(float scale)
|
||||
// @tparam Vec3 scale New world scale.
|
||||
void Static::SetScale(const Vec3& scale)
|
||||
{
|
||||
_static.scale = scale;
|
||||
_static.Transform.Scale = scale.ToVector3();
|
||||
_static.Dirty = true;
|
||||
}
|
||||
|
||||
|
@ -192,12 +204,12 @@ namespace TEN::Scripting
|
|||
// @tparam Color color New color.
|
||||
void Static::SetColor(ScriptColor const& col)
|
||||
{
|
||||
_static.color = col;
|
||||
_static.Color = col;
|
||||
_static.Dirty = true;
|
||||
}
|
||||
|
||||
/// Set this static's hit points. Used only with shatterable statics.
|
||||
// @function Static:SetHP
|
||||
// @function Static:SetHitPoints
|
||||
// @tparam int hitPoints New hit points.
|
||||
void Static::SetHitPoints(int hitPoints)
|
||||
{
|
||||
|
@ -211,11 +223,11 @@ namespace TEN::Scripting
|
|||
{
|
||||
if (status)
|
||||
{
|
||||
_static.flags |= StaticMeshFlags::SM_SOLID;
|
||||
_static.Flags |= StaticMeshFlags::SM_SOLID;
|
||||
}
|
||||
else
|
||||
{
|
||||
_static.flags &= ~StaticMeshFlags::SM_SOLID;
|
||||
_static.Flags &= ~StaticMeshFlags::SM_SOLID;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,20 +235,26 @@ namespace TEN::Scripting
|
|||
// @function Static:Enable
|
||||
void Static::Enable()
|
||||
{
|
||||
_static.flags |= StaticMeshFlags::SM_VISIBLE;
|
||||
_static.Flags |= StaticMeshFlags::SM_VISIBLE;
|
||||
}
|
||||
|
||||
/// Disable this static.
|
||||
// @function Static:Disable
|
||||
void Static::Disable()
|
||||
{
|
||||
_static.flags &= ~StaticMeshFlags::SM_VISIBLE;
|
||||
_static.Flags &= ~StaticMeshFlags::SM_VISIBLE;
|
||||
}
|
||||
|
||||
/// Shatter this static.
|
||||
// @function Static:Shatter
|
||||
void Static::Shatter()
|
||||
{
|
||||
ShatterObject(nullptr, &_static, -128, _static.roomNumber, 0);
|
||||
ShatterObject(nullptr, &_static, -128, _static.RoomNumber, 0);
|
||||
}
|
||||
|
||||
void Static::SetScale(float scale)
|
||||
{
|
||||
_static.Transform.Scale = Vector3(scale);
|
||||
_static.Dirty = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace sol { class state; }
|
||||
|
||||
enum GAME_OBJECT_ID : short;
|
||||
class Vec3;
|
||||
namespace TEN::Scripting::Types { class ScriptColor; }
|
||||
|
||||
|
@ -37,23 +38,23 @@ namespace TEN::Scripting
|
|||
|
||||
// Getters
|
||||
|
||||
std::string GetName() const;
|
||||
int GetSlot() const;
|
||||
Vec3 GetPosition() const;
|
||||
Rotation GetRotation() const;
|
||||
float GetScale() const;
|
||||
ScriptColor GetColor() const;
|
||||
int GetHitPoints() const;
|
||||
bool GetActiveStatus() const;
|
||||
bool GetSolidStatus() const;
|
||||
std::string GetName() const;
|
||||
GAME_OBJECT_ID GetObjectId() const;
|
||||
Vec3 GetPosition() const;
|
||||
Rotation GetRotation() const;
|
||||
Vec3 GetScale() const;
|
||||
ScriptColor GetColor() const;
|
||||
int GetHitPoints() const;
|
||||
bool GetActiveStatus() const;
|
||||
bool GetSolidStatus() const;
|
||||
|
||||
// Setters
|
||||
|
||||
void SetName(const std::string& name);
|
||||
void SetSlot(int slotID);
|
||||
void SetObjectId(GAME_OBJECT_ID objectId);
|
||||
void SetPosition(const Vec3& pos);
|
||||
void SetRotation(const Rotation& rot);
|
||||
void SetScale(float scale);
|
||||
void SetScale(const Vec3& scale);
|
||||
void SetColor(const ScriptColor& color);
|
||||
void SetHitPoints(int hitPoints);
|
||||
void SetSolidStatus(bool status);
|
||||
|
@ -67,5 +68,9 @@ namespace TEN::Scripting
|
|||
// Operators
|
||||
|
||||
Static& operator =(const Static& staticObj) = delete;
|
||||
|
||||
// COMPATIBILITY
|
||||
|
||||
void SetScale(float scale);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -720,17 +720,17 @@ void LoadDynamicRoomData()
|
|||
{
|
||||
auto& mesh = room.mesh.emplace_back();
|
||||
|
||||
mesh.roomNumber = i;
|
||||
mesh.pos.Position.x = ReadInt32();
|
||||
mesh.pos.Position.y = ReadInt32();
|
||||
mesh.pos.Position.z = ReadInt32();
|
||||
mesh.pos.Orientation.y = ReadUInt16();
|
||||
mesh.pos.Orientation.x = ReadUInt16();
|
||||
mesh.pos.Orientation.z = ReadUInt16();
|
||||
mesh.scale = ReadFloat();
|
||||
mesh.flags = ReadUInt16();
|
||||
mesh.color = ReadVector4();
|
||||
mesh.staticNumber = ReadUInt16();
|
||||
mesh.RoomNumber = i;
|
||||
mesh.Transform.Position.x = ReadInt32();
|
||||
mesh.Transform.Position.y = ReadInt32();
|
||||
mesh.Transform.Position.z = ReadInt32();
|
||||
mesh.Transform.Orientation.y = ReadUInt16();
|
||||
mesh.Transform.Orientation.x = ReadUInt16();
|
||||
mesh.Transform.Orientation.z = ReadUInt16();
|
||||
mesh.Transform.Scale = Vector3(ReadFloat()); // TODO: Write Vector3 scale to level.
|
||||
mesh.Flags = ReadUInt16();
|
||||
mesh.Color = ReadVector4();
|
||||
mesh.ObjectId = (GAME_OBJECT_ID)ReadUInt16();
|
||||
mesh.HitPoints = ReadInt16();
|
||||
mesh.Name = ReadString();
|
||||
|
||||
|
|
|
@ -4791,10 +4791,9 @@ flatbuffers::Offset<Sink> CreateSink(flatbuffers::FlatBufferBuilder &_fbb, const
|
|||
|
||||
struct StaticMeshInfoT : public flatbuffers::NativeTable {
|
||||
typedef StaticMeshInfo TableType;
|
||||
int32_t number = 0;
|
||||
int32_t id = 0;
|
||||
std::unique_ptr<TEN::Save::Pose> transform{};
|
||||
int32_t room_number = 0;
|
||||
std::unique_ptr<TEN::Save::Pose> pose{};
|
||||
float scale = 0.0f;
|
||||
std::unique_ptr<TEN::Save::Vector4> color{};
|
||||
int32_t hit_points = 0;
|
||||
int32_t flags = 0;
|
||||
|
@ -4805,26 +4804,22 @@ struct StaticMeshInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
|||
typedef StaticMeshInfoBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_NUMBER = 4,
|
||||
VT_ROOM_NUMBER = 6,
|
||||
VT_POSE = 8,
|
||||
VT_SCALE = 10,
|
||||
VT_COLOR = 12,
|
||||
VT_HIT_POINTS = 14,
|
||||
VT_FLAGS = 16
|
||||
VT_ID = 4,
|
||||
VT_TRANSFORM = 6,
|
||||
VT_ROOM_NUMBER = 8,
|
||||
VT_COLOR = 10,
|
||||
VT_HIT_POINTS = 12,
|
||||
VT_FLAGS = 14
|
||||
};
|
||||
int32_t number() const {
|
||||
return GetField<int32_t>(VT_NUMBER, 0);
|
||||
int32_t id() const {
|
||||
return GetField<int32_t>(VT_ID, 0);
|
||||
}
|
||||
const TEN::Save::Pose *transform() const {
|
||||
return GetStruct<const TEN::Save::Pose *>(VT_TRANSFORM);
|
||||
}
|
||||
int32_t room_number() const {
|
||||
return GetField<int32_t>(VT_ROOM_NUMBER, 0);
|
||||
}
|
||||
const TEN::Save::Pose *pose() const {
|
||||
return GetStruct<const TEN::Save::Pose *>(VT_POSE);
|
||||
}
|
||||
float scale() const {
|
||||
return GetField<float>(VT_SCALE, 0.0f);
|
||||
}
|
||||
const TEN::Save::Vector4 *color() const {
|
||||
return GetStruct<const TEN::Save::Vector4 *>(VT_COLOR);
|
||||
}
|
||||
|
@ -4836,10 +4831,9 @@ struct StaticMeshInfo FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
|||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, VT_NUMBER) &&
|
||||
VerifyField<int32_t>(verifier, VT_ID) &&
|
||||
VerifyField<TEN::Save::Pose>(verifier, VT_TRANSFORM) &&
|
||||
VerifyField<int32_t>(verifier, VT_ROOM_NUMBER) &&
|
||||
VerifyField<TEN::Save::Pose>(verifier, VT_POSE) &&
|
||||
VerifyField<float>(verifier, VT_SCALE) &&
|
||||
VerifyField<TEN::Save::Vector4>(verifier, VT_COLOR) &&
|
||||
VerifyField<int32_t>(verifier, VT_HIT_POINTS) &&
|
||||
VerifyField<int32_t>(verifier, VT_FLAGS) &&
|
||||
|
@ -4854,18 +4848,15 @@ struct StaticMeshInfoBuilder {
|
|||
typedef StaticMeshInfo Table;
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_number(int32_t number) {
|
||||
fbb_.AddElement<int32_t>(StaticMeshInfo::VT_NUMBER, number, 0);
|
||||
void add_id(int32_t id) {
|
||||
fbb_.AddElement<int32_t>(StaticMeshInfo::VT_ID, id, 0);
|
||||
}
|
||||
void add_transform(const TEN::Save::Pose *transform) {
|
||||
fbb_.AddStruct(StaticMeshInfo::VT_TRANSFORM, transform);
|
||||
}
|
||||
void add_room_number(int32_t room_number) {
|
||||
fbb_.AddElement<int32_t>(StaticMeshInfo::VT_ROOM_NUMBER, room_number, 0);
|
||||
}
|
||||
void add_pose(const TEN::Save::Pose *pose) {
|
||||
fbb_.AddStruct(StaticMeshInfo::VT_POSE, pose);
|
||||
}
|
||||
void add_scale(float scale) {
|
||||
fbb_.AddElement<float>(StaticMeshInfo::VT_SCALE, scale, 0.0f);
|
||||
}
|
||||
void add_color(const TEN::Save::Vector4 *color) {
|
||||
fbb_.AddStruct(StaticMeshInfo::VT_COLOR, color);
|
||||
}
|
||||
|
@ -4888,10 +4879,9 @@ struct StaticMeshInfoBuilder {
|
|||
|
||||
inline flatbuffers::Offset<StaticMeshInfo> CreateStaticMeshInfo(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t number = 0,
|
||||
int32_t id = 0,
|
||||
const TEN::Save::Pose *transform = 0,
|
||||
int32_t room_number = 0,
|
||||
const TEN::Save::Pose *pose = 0,
|
||||
float scale = 0.0f,
|
||||
const TEN::Save::Vector4 *color = 0,
|
||||
int32_t hit_points = 0,
|
||||
int32_t flags = 0) {
|
||||
|
@ -4899,10 +4889,9 @@ inline flatbuffers::Offset<StaticMeshInfo> CreateStaticMeshInfo(
|
|||
builder_.add_flags(flags);
|
||||
builder_.add_hit_points(hit_points);
|
||||
builder_.add_color(color);
|
||||
builder_.add_scale(scale);
|
||||
builder_.add_pose(pose);
|
||||
builder_.add_room_number(room_number);
|
||||
builder_.add_number(number);
|
||||
builder_.add_transform(transform);
|
||||
builder_.add_id(id);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
|
@ -9727,10 +9716,9 @@ inline StaticMeshInfoT *StaticMeshInfo::UnPack(const flatbuffers::resolver_funct
|
|||
inline void StaticMeshInfo::UnPackTo(StaticMeshInfoT *_o, const flatbuffers::resolver_function_t *_resolver) const {
|
||||
(void)_o;
|
||||
(void)_resolver;
|
||||
{ auto _e = number(); _o->number = _e; }
|
||||
{ auto _e = id(); _o->id = _e; }
|
||||
{ auto _e = transform(); if (_e) _o->transform = std::unique_ptr<TEN::Save::Pose>(new TEN::Save::Pose(*_e)); }
|
||||
{ auto _e = room_number(); _o->room_number = _e; }
|
||||
{ auto _e = pose(); if (_e) _o->pose = std::unique_ptr<TEN::Save::Pose>(new TEN::Save::Pose(*_e)); }
|
||||
{ auto _e = scale(); _o->scale = _e; }
|
||||
{ auto _e = color(); if (_e) _o->color = std::unique_ptr<TEN::Save::Vector4>(new TEN::Save::Vector4(*_e)); }
|
||||
{ auto _e = hit_points(); _o->hit_points = _e; }
|
||||
{ auto _e = flags(); _o->flags = _e; }
|
||||
|
@ -9744,19 +9732,17 @@ inline flatbuffers::Offset<StaticMeshInfo> CreateStaticMeshInfo(flatbuffers::Fla
|
|||
(void)_rehasher;
|
||||
(void)_o;
|
||||
struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StaticMeshInfoT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||
auto _number = _o->number;
|
||||
auto _id = _o->id;
|
||||
auto _transform = _o->transform ? _o->transform.get() : 0;
|
||||
auto _room_number = _o->room_number;
|
||||
auto _pose = _o->pose ? _o->pose.get() : 0;
|
||||
auto _scale = _o->scale;
|
||||
auto _color = _o->color ? _o->color.get() : 0;
|
||||
auto _hit_points = _o->hit_points;
|
||||
auto _flags = _o->flags;
|
||||
return TEN::Save::CreateStaticMeshInfo(
|
||||
_fbb,
|
||||
_number,
|
||||
_id,
|
||||
_transform,
|
||||
_room_number,
|
||||
_pose,
|
||||
_scale,
|
||||
_color,
|
||||
_hit_points,
|
||||
_flags);
|
||||
|
|
|
@ -326,10 +326,9 @@ table Sink {
|
|||
}
|
||||
|
||||
table StaticMeshInfo {
|
||||
number: int32;
|
||||
id: int32;
|
||||
transform: Pose;
|
||||
room_number: int32;
|
||||
pose: Pose;
|
||||
scale: float;
|
||||
color: Vector4;
|
||||
hit_points: int32;
|
||||
flags: int32;
|
||||
|
|
|
@ -532,6 +532,7 @@ if not exist "%ScriptsDir%\Strings.lua" xcopy /Y "$(SolutionDir)Scripts\Strings.
|
|||
<ClInclude Include="Game\savegame.h" />
|
||||
<ClInclude Include="Game\Setup.h" />
|
||||
<ClInclude Include="Game\spotcam.h" />
|
||||
<ClInclude Include="Game\StaticObject.h" />
|
||||
<ClInclude Include="Math\Constants.h" />
|
||||
<ClInclude Include="Math\Geometry.h" />
|
||||
<ClInclude Include="Math\Legacy.h" />
|
||||
|
@ -1062,6 +1063,7 @@ if not exist "%ScriptsDir%\Strings.lua" xcopy /Y "$(SolutionDir)Scripts\Strings.
|
|||
<ClCompile Include="Game\savegame.cpp" />
|
||||
<ClCompile Include="Game\Setup.cpp" />
|
||||
<ClCompile Include="Game\spotcam.cpp" />
|
||||
<ClCompile Include="Game\StaticObject.cpp" />
|
||||
<ClCompile Include="Math\Geometry.cpp" />
|
||||
<ClCompile Include="Math\Legacy.cpp" />
|
||||
<ClCompile Include="Math\Objects\AxisAngle.cpp" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue