Skip to content

Commit

Permalink
Refactor GameObject class hierarchy.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Dec 4, 2015
1 parent 96b2baa commit 3b80257
Show file tree
Hide file tree
Showing 549 changed files with 2,465 additions and 2,345 deletions.
8 changes: 4 additions & 4 deletions src/Layers/xrRender/LightTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void CROS_impl::update (IRenderable* O)
VERIFY (dynamic_cast<CROS_impl*> (O->renderable_ROS()));
//float dt = Device.fTimeDelta;

CObject* _object = dynamic_cast<CObject*> (O);
IGameObject* _object = dynamic_cast<IGameObject*> (O);

// select sample, randomize position inside object
vis_data &vis = O->GetRenderData().visual->getVisData();
Expand Down Expand Up @@ -360,7 +360,7 @@ void CROS_impl::update_smooth (IRenderable* O)
}
}

void CROS_impl::calc_sun_value(Fvector& position, CObject* _object)
void CROS_impl::calc_sun_value(Fvector& position, IGameObject* _object)
{

#if RENDER==R_R1
Expand All @@ -377,7 +377,7 @@ void CROS_impl::calc_sun_value(Fvector& position, CObject* _object)
}
}

void CROS_impl::calc_sky_hemi_value(Fvector& position, CObject* _object)
void CROS_impl::calc_sky_hemi_value(Fvector& position, IGameObject* _object)
{
// hemi-tracing
if (MODE & IRender_ObjectSpecific::TRACE_HEMI)
Expand Down Expand Up @@ -419,7 +419,7 @@ void CROS_impl::calc_sky_hemi_value(Fvector& position, CObject* _object)

void CROS_impl::prepare_lights(Fvector& position, IRenderable* O)
{
CObject* _object = dynamic_cast<CObject*> (O);
IGameObject* _object = dynamic_cast<IGameObject*> (O);
float dt = Device.fTimeDelta;

vis_data &vis = O->GetRenderData().visual->getVisData();
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/LightTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ class CROS_impl : public IRender_ObjectSpecific
static inline void accum_hemi(float* hemi_cube, Fvector3& dir, float scale);

//Calculates sun part of ambient occlusion
void calc_sun_value(Fvector& position, CObject* _object);
void calc_sun_value(Fvector& position, IGameObject* _object);

//Calculates sky part of ambient occlusion
void calc_sky_hemi_value(Fvector& position, CObject* _object);
void calc_sky_hemi_value(Fvector& position, IGameObject* _object);

//prepares static or hemisphere lights for ambient occlusion calculations
void prepare_lights(Fvector& position, IRenderable* O);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderDX10/3DFluid/dx103DFluidObstacles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void dx103DFluidObstacles::ProcessDynamicObstacles( const dx103DFluidData &Fluid
// renderable
//IRenderable* renderable = spatial->dcast_Renderable ();
//if (0==renderable) continue; // unknown, but renderable object (r1_glow???)
CObject* pObject = spatial->dcast_CObject();
IGameObject* pObject = spatial->dcast_GameObject();
if (!pObject) continue;

const IObjectPhysicsCollision* pCollision = pObject->physics_collision();
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRenderPC_R1/FStaticRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void CRender::set_Object (IRenderable* O )
VERIFY (g_bRendering);
val_pObject = O; // NULL is OK, trust me :)
if (val_pObject) {
VERIFY(dynamic_cast<CObject*>(O)||dynamic_cast<CPS_Instance*>(O));
VERIFY(dynamic_cast<IGameObject*>(O)||dynamic_cast<CPS_Instance*>(O));
if (O->GetRenderData().pROS) { VERIFY(dynamic_cast<CROS_impl*>(O->GetRenderData().pROS)); }
}
if (PHASE_NORMAL==phase) {
Expand All @@ -288,7 +288,7 @@ void CRender::apply_object (IRenderable* O )
if (0==O) return ;
if (PHASE_NORMAL==phase && O->renderable_ROS()) {
CROS_impl& LT = *((CROS_impl*)O->GetRenderData().pROS);
VERIFY(dynamic_cast<CObject*>(O)||dynamic_cast<CPS_Instance*>(O));
VERIFY(dynamic_cast<IGameObject*>(O)||dynamic_cast<CPS_Instance*>(O));
VERIFY(dynamic_cast<CROS_impl*>(O->GetRenderData().pROS));
float o_hemi = 0.5f*LT.get_hemi ();
float o_sun = 0.5f*LT.get_sun ();
Expand Down Expand Up @@ -445,7 +445,7 @@ void CRender::Calculate ()
if (lstRenderables.size()) uID_LTRACK = uLastLTRACK%lstRenderables.size();

// update light-vis for current entity / actor
CObject* O = g_pGameLevel->CurrentViewEntity();
IGameObject* O = g_pGameLevel->CurrentViewEntity();
if (O) {
CROS_impl* R = (CROS_impl*) O->ROS();
if (R) R->update (O);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R1/GlowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void CGlowManager::Render ()
void CGlowManager::render_sw ()
{
// 0. save main view and disable
CObject* o_main = g_pGameLevel->CurrentViewEntity();
IGameObject* o_main = g_pGameLevel->CurrentViewEntity();

// 1. Test some number of glows
Fvector start = Device.vCameraPosition;
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R1/LightProjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void CLightProjector::set_object (IRenderable* O)
else {
spatial->spatial_updatesector ();
if (0==spatial->GetSpatialData().sector) {
CObject* obj = dynamic_cast<CObject*>(O);
IGameObject* obj = dynamic_cast<IGameObject*>(O);
if (obj) Msg ("! Invalid object '%s' position. Outside of sector structure.",obj->cName().c_str());
current = 0;
}
Expand Down Expand Up @@ -218,7 +218,7 @@ void CLightProjector::calculate ()
v.sub (v_Cs,v_C);;
#ifdef DEBUG
if ((v.x*v.x+v.y*v.y+v.z*v.z)<=flt_zero) {
CObject* OO = dynamic_cast<CObject*>(R.O);
IGameObject* OO = dynamic_cast<IGameObject*>(R.O);
Msg("Object[%s] Visual[%s] has invalid position. ",*OO->cName(),*OO->cNameVisual());
Fvector cc;
OO->Center(cc);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R2/r2_R_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
if (lstRenderables.size()) uID_LTRACK = uLastLTRACK%lstRenderables.size();

// update light-vis for current entity / actor
CObject* O = g_pGameLevel->CurrentViewEntity();
IGameObject* O = g_pGameLevel->CurrentViewEntity();
if (O) {
CROS_impl* R = (CROS_impl*) O->ROS();
if (R) R->update (O);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R3/r3_R_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
if (lstRenderables.size()) uID_LTRACK = uLastLTRACK%lstRenderables.size();

// update light-vis for current entity / actor
CObject* O = g_pGameLevel->CurrentViewEntity();
IGameObject* O = g_pGameLevel->CurrentViewEntity();
if (O) {
CROS_impl* R = (CROS_impl*) O->ROS();
if (R) R->update (O);
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/r4_R_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
if (lstRenderables.size()) uID_LTRACK = uLastLTRACK%lstRenderables.size();

// update light-vis for current entity / actor
CObject* O = g_pGameLevel->CurrentViewEntity();
IGameObject* O = g_pGameLevel->CurrentViewEntity();
if (O) {
CROS_impl* R = (CROS_impl*) O->ROS();
if (R) R->update (O);
Expand Down
2 changes: 1 addition & 1 deletion src/xrCDB/ISpatial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void ISpatial_DB::insert (ISpatial* S)
BOOL bValid = _valid(S->GetSpatialData().sphere.R) && _valid(S->GetSpatialData().sphere.P);
if (!bValid)
{
CObject* O = dynamic_cast<CObject*>(S);
IGameObject* O = dynamic_cast<IGameObject*>(S);
if (O) Debug.fatal(DEBUG_INFO,"Invalid OBJECT position or radius (%s)",O->cName().c_str());
else {
CPS_Instance* P = dynamic_cast<CPS_Instance*>(S);
Expand Down
9 changes: 5 additions & 4 deletions src/xrCDB/ISpatial.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum

//////////////////////////////////////////////////////////////////////////
// Fast type conversion
//class CObject;
//class IGameObject;
//class IRenderable;
//class IRender_Light;
//
Expand All @@ -68,6 +68,7 @@ enum
class ISpatial_NODE;
class IRender_Sector;
class ISpatial_DB;
class IGameObject;
namespace Feel { class Sound; }
class IRenderable;
class IRender_Light;
Expand Down Expand Up @@ -95,15 +96,15 @@ class ISpatial
virtual void spatial_move() = 0;
virtual Fvector spatial_sector_point() = 0;
virtual void spatial_updatesector() = 0;
virtual CObject *dcast_CObject() = 0;
virtual IGameObject *dcast_GameObject() = 0;
virtual Feel::Sound *dcast_FeelSound() = 0;
virtual IRenderable *dcast_Renderable() = 0;
virtual IRender_Light *dcast_Light() = 0;
};

inline ISpatial::~ISpatial() {}

class XRCDB_API SpatialBase : public ISpatial
class XRCDB_API SpatialBase : public virtual ISpatial
{
public:
SpatialData spatial;
Expand All @@ -125,7 +126,7 @@ class XRCDB_API SpatialBase : public ISpatial
spatial_updatesector_internal () ;
}

virtual CObject *dcast_CObject() override { return 0; }
virtual IGameObject *dcast_GameObject() override { return 0; }
virtual Feel::Sound *dcast_FeelSound() override { return 0; }
virtual IRenderable *dcast_Renderable() override { return 0; }
virtual IRender_Light *dcast_Light() override { return 0; }
Expand Down
10 changes: 5 additions & 5 deletions src/xrCDB/xr_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CObjectSpace::~CObjectSpace ( )
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int CObjectSpace::GetNearest ( xr_vector<ISpatial*>& q_spatial, xr_vector<CObject*>& q_nearest, const Fvector &point, float range, CObject* ignore_object )
int CObjectSpace::GetNearest ( xr_vector<ISpatial*>& q_spatial, xr_vector<IGameObject*>& q_nearest, const Fvector &point, float range, IGameObject* ignore_object )
{
q_spatial.clear_not_free ( );
// Query objects
Expand All @@ -59,7 +59,7 @@ int CObjectSpace::GetNearest ( xr_vector<ISpatial*>& q_spatial, xr_vector<CObje
xr_vector<ISpatial*>::iterator it = q_spatial.begin ();
xr_vector<ISpatial*>::iterator end = q_spatial.end ();
for (; it!=end; it++) {
CObject* O = (*it)->dcast_CObject ();
IGameObject* O = (*it)->dcast_GameObject ();
if (0==O) continue;
if (O==ignore_object) continue;
Fsphere mS = { O->GetSpatialData().sphere.P, O->GetSpatialData().sphere.R };
Expand All @@ -70,7 +70,7 @@ int CObjectSpace::GetNearest ( xr_vector<ISpatial*>& q_spatial, xr_vector<CObje
}

//----------------------------------------------------------------------
IC int CObjectSpace::GetNearest ( xr_vector<CObject*>& q_nearest, const Fvector &point, float range, CObject* ignore_object )
IC int CObjectSpace::GetNearest ( xr_vector<IGameObject*>& q_nearest, const Fvector &point, float range, IGameObject* ignore_object )
{
return (
GetNearest(
Expand All @@ -84,9 +84,9 @@ IC int CObjectSpace::GetNearest ( xr_vector<CObject*>& q_nearest, const Fvector
}

//----------------------------------------------------------------------
IC int CObjectSpace::GetNearest( xr_vector<CObject*>& q_nearest, ICollisionForm* obj, float range)
IC int CObjectSpace::GetNearest( xr_vector<IGameObject*>& q_nearest, ICollisionForm* obj, float range)
{
CObject* O = obj->Owner ();
IGameObject* O = obj->Owner ();
return GetNearest( q_nearest, O->GetSpatialData().sphere.P, range + O->GetSpatialData().sphere.R, O );
}

Expand Down
24 changes: 12 additions & 12 deletions src/xrCDB/xr_area.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// refs
class ISpatial;
class ICollisionForm;
class CObject;
class IGameObject;

#include "Include/xrRender/FactoryPtr.h"
#include "Include/xrRender/ObjectSpaceRender.h"
Expand Down Expand Up @@ -39,11 +39,11 @@ class XRCDB_API CObjectSpace
#endif

private:
BOOL _RayTest ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::ray_cache* cache, CObject* ignore_object);
BOOL _RayPick ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::rq_result& R, CObject* ignore_object );
BOOL _RayQuery ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, CObject* ignore_object);
BOOL _RayQuery2 ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, CObject* ignore_object);
BOOL _RayQuery3 ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, CObject* ignore_object);
BOOL _RayTest ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::ray_cache* cache, IGameObject* ignore_object);
BOOL _RayPick ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::rq_result& R, IGameObject* ignore_object );
BOOL _RayQuery ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, IGameObject* ignore_object);
BOOL _RayQuery2 ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, IGameObject* ignore_object);
BOOL _RayQuery3 ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, IGameObject* ignore_object);
public:
CObjectSpace ( );
~CObjectSpace ( );
Expand All @@ -53,13 +53,13 @@ class XRCDB_API CObjectSpace
void Load ( IReader* R, CDB::build_callback build_callback );
void Create ( Fvector* verts, CDB::TRI* tris, const hdrCFORM &H, CDB::build_callback build_callback );
// Occluded/No
BOOL RayTest ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::ray_cache* cache, CObject* ignore_object);
BOOL RayTest ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::ray_cache* cache, IGameObject* ignore_object);

// Game raypick (nearest) - returns object and addititional params
BOOL RayPick ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::rq_result& R, CObject* ignore_object );
BOOL RayPick ( const Fvector &start, const Fvector &dir, float range, collide::rq_target tgt, collide::rq_result& R, IGameObject* ignore_object );

// General collision query
BOOL RayQuery ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, CObject* ignore_object);
BOOL RayQuery ( collide::rq_results& dest, const collide::ray_defs& rq, collide::rq_callback* cb, LPVOID user_data, collide::test_callback* tb, IGameObject* ignore_object);
BOOL RayQuery ( collide::rq_results& dest, ICollisionForm* target, const collide::ray_defs& rq);

bool BoxQuery ( Fvector const & box_center,
Expand All @@ -68,9 +68,9 @@ class XRCDB_API CObjectSpace
Fvector const & box_sizes,
xr_vector<Fvector> * out_tris );

int GetNearest ( xr_vector<CObject*>& q_nearest, ICollisionForm *obj, float range );
int GetNearest ( xr_vector<CObject*>& q_nearest, const Fvector &point, float range, CObject* ignore_object );
int GetNearest ( xr_vector<ISpatial*>& q_spatial, xr_vector<CObject*>& q_nearest, const Fvector &point, float range, CObject* ignore_object );
int GetNearest ( xr_vector<IGameObject*>& q_nearest, ICollisionForm *obj, float range );
int GetNearest ( xr_vector<IGameObject*>& q_nearest, const Fvector &point, float range, IGameObject* ignore_object );
int GetNearest ( xr_vector<ISpatial*>& q_spatial, xr_vector<IGameObject*>& q_nearest, const Fvector &point, float range, IGameObject* ignore_object );

CDB::TRI* GetStaticTris () { return Static.get_tris(); }
Fvector* GetStaticVerts () { return Static.get_verts(); }
Expand Down
2 changes: 1 addition & 1 deletion src/xrCDB/xr_area_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void CObjectSpace::BoxQuery (collide::rq_results& r_dest, const Fbox& B, const F
for (u32 o_it=0; o_it<r_spatial.size(); o_it++)
{
ISpatial* spatial = r_spatial[o_it];
CObject* collidable = spatial->dcast_CObject ();
IGameObject* collidable = spatial->dcast_GameObject ();
if (0==collidable) continue;
collidable->collidable.model->_BoxQuery (B,M,flags);
}
Expand Down
Loading

0 comments on commit 3b80257

Please sign in to comment.