Add CalcWorldBoundingVolumes (#651)

This commit is contained in:
Christian Semmler 2024-03-10 10:29:16 -04:00 committed by GitHub
parent 660c1e1170
commit d090b449d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 40 additions and 3 deletions

View file

@ -4,6 +4,7 @@
#include "legonotify.h" #include "legonotify.h"
#include "legovideomanager.h" #include "legovideomanager.h"
#include "misc.h" #include "misc.h"
#include "realtime/realtime.h"
DECOMP_SIZE_ASSERT(LegoCameraController, 0xc8); DECOMP_SIZE_ASSERT(LegoCameraController, 0xc8);

View file

@ -9,6 +9,7 @@
#include "legoworld.h" #include "legoworld.h"
#include "misc.h" #include "misc.h"
#include "mxmisc.h" #include "mxmisc.h"
#include "realtime/realtime.h"
DECOMP_SIZE_ASSERT(LegoEntity, 0x68) DECOMP_SIZE_ASSERT(LegoEntity, 0x68)

View file

@ -11,6 +11,7 @@
#include "mxstreamchunk.h" #include "mxstreamchunk.h"
#include "mxtimer.h" #include "mxtimer.h"
#include "mxvideomanager.h" #include "mxvideomanager.h"
#include "realtime/realtime.h"
DECOMP_SIZE_ASSERT(LegoAnimPresenter, 0xc0) DECOMP_SIZE_ASSERT(LegoAnimPresenter, 0xc0)

View file

@ -13,6 +13,7 @@
#include "misc/version.h" #include "misc/version.h"
#include "mxcompositepresenter.h" #include "mxcompositepresenter.h"
#include "mxutilities.h" #include "mxutilities.h"
#include "realtime/realtime.h"
#include "roi/legoroi.h" #include "roi/legoroi.h"
// GLOBAL: LEGO1 0x100f7ae0 // GLOBAL: LEGO1 0x100f7ae0

View file

@ -6,6 +6,7 @@
#include "mxtimer.h" #include "mxtimer.h"
#include "mxtransitionmanager.h" #include "mxtransitionmanager.h"
#include "realtime/matrix.h" #include "realtime/matrix.h"
#include "realtime/realtime.h"
#include "roi/legoroi.h" #include "roi/legoroi.h"
#include "tgl/d3drm/impl.h" #include "tgl/d3drm/impl.h"
#include "viewmanager/viewroi.h" #include "viewmanager/viewroi.h"

View file

@ -6,6 +6,7 @@
#include "legolod.h" #include "legolod.h"
#include "misc/legocontainer.h" #include "misc/legocontainer.h"
#include "misc/legostorage.h" #include "misc/legostorage.h"
#include "realtime/realtime.h"
#include <string.h> #include <string.h>
#include <vec.h> #include <vec.h>
@ -539,8 +540,8 @@ float LegoROI::IntrinsicImportance() const
return .5; return .5;
} }
// STUB: LEGO1 0x100aa350 // FUNCTION: LEGO1 0x100aa350
void LegoROI::UpdateWorldBoundingVolumes() void LegoROI::UpdateWorldBoundingVolumes()
{ {
// TODO CalcWorldBoundingVolumes(m_sphere, m_local2world, m_world_bounding_box, m_world_bounding_sphere);
} }

View file

@ -131,6 +131,32 @@ void OrientableROI::UpdateWorldVelocity()
{ {
} }
// FUNCTION: LEGO1 0x100a5a60
void CalcWorldBoundingVolumes(
const BoundingSphere& modelling_sphere,
const Matrix4& local2world,
BoundingBox& world_bounding_box,
BoundingSphere& world_bounding_sphere
)
{
// calculate world bounding volumes given a bounding sphere in modelling
// space and local2world transform
// ??? we need to transform the radius too... if scaling...
V3XM4(world_bounding_sphere.Center(), modelling_sphere.Center(), local2world);
world_bounding_sphere.Radius() = modelling_sphere.Radius();
// update world_bounding_box
world_bounding_box.Min()[0] = world_bounding_sphere.Center()[0] - world_bounding_sphere.Radius();
world_bounding_box.Min()[1] = world_bounding_sphere.Center()[1] - world_bounding_sphere.Radius();
world_bounding_box.Min()[2] = world_bounding_sphere.Center()[2] - world_bounding_sphere.Radius();
world_bounding_box.Max()[0] = world_bounding_sphere.Center()[0] + world_bounding_sphere.Radius();
world_bounding_box.Max()[1] = world_bounding_sphere.Center()[1] + world_bounding_sphere.Radius();
world_bounding_box.Max()[2] = world_bounding_sphere.Center()[2] + world_bounding_sphere.Radius();
}
// FUNCTION: LEGO1 0x100a5d80 // FUNCTION: LEGO1 0x100a5d80
const float* OrientableROI::GetWorldVelocity() const const float* OrientableROI::GetWorldVelocity() const
{ {

View file

@ -2,6 +2,7 @@
#define REALTIME_H #define REALTIME_H
#include "matrix.h" #include "matrix.h"
#include "roi.h"
#define NORMVEC3(dst, src) \ #define NORMVEC3(dst, src) \
{ \ { \
@ -11,4 +12,8 @@
void CalcLocalTransform(const Vector3& p_posVec, const Vector3& p_dirVec, const Vector3& p_upVec, Matrix4& p_outMatrix); void CalcLocalTransform(const Vector3& p_posVec, const Vector3& p_dirVec, const Vector3& p_upVec, Matrix4& p_outMatrix);
// utility to help derived ROI classes implement
// update_world_bounding_volumes() using a modelling sphere
void CalcWorldBoundingVolumes(const BoundingSphere& modelling_sphere, const Matrix4& local2world, BoundingBox&, BoundingSphere&);
#endif // REALTIME_H #endif // REALTIME_H

View file

@ -4,10 +4,10 @@
// ROI stands for Real-time Object Instance. // ROI stands for Real-time Object Instance.
#include "compat.h" #include "compat.h"
#include "decomp.h"
#include "lodlist.h" #include "lodlist.h"
#include "mxgeometry/mxgeometry3d.h" #include "mxgeometry/mxgeometry3d.h"
#include "mxstl/stlcompat.h" #include "mxstl/stlcompat.h"
#include "realtime/realtime.h"
/* /*
* A simple bounding box object with Min and Max accessor methods. * A simple bounding box object with Min and Max accessor methods.