Skip to content

Commit

Permalink
ISpatial: move data to SpatialBase.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Nov 10, 2015
1 parent 8560904 commit 8e77ee9
Show file tree
Hide file tree
Showing 39 changed files with 171 additions and 146 deletions.
4 changes: 2 additions & 2 deletions src/Layers/xrRender/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
static const float SQRT2 = 1.4142135623730950488016887242097f;
static const float RSQRTDIV2 = 0.70710678118654752440084436210485f;

light::light (void) : ISpatial(g_SpatialSpace)
light::light (void) : SpatialBase(g_SpatialSpace)
{
spatial.type = STYPE_LIGHTSOURCE;
flags.type = POINT;
Expand Down Expand Up @@ -192,7 +192,7 @@ void light::spatial_move ()
}

// update spatial DB
ISpatial::spatial_move ();
SpatialBase::spatial_move ();

#if (RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4)
if (flags.bActive) gi_generate ();
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# include "light_GI.h"
#endif //(RENDER==R_R2) || (RENDER==R_R3) || (RENDER==R_R4)

class light : public IRender_Light, public ISpatial
class light : public IRender_Light, public SpatialBase
{
public:
struct {
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/r__dsgraph_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,13 @@ void D3DXRenderBase::r_dsgraph_render_subspace (IRender_Sector* _sector, CFrustu
for (u32 o_it=0; o_it<lstRenderables.size(); o_it++)
{
ISpatial* spatial = lstRenderables[o_it];
CSector* sector = (CSector*)spatial->spatial.sector;
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
if (0==sector) continue; // disassociated from S/P structure
if (PortalTraverser.i_marker != sector->r_marker) continue; // inactive (untouched) sector
for (u32 v_it=0; v_it<sector->r_frustums.size(); v_it++)
{
set_Frustum (&(sector->r_frustums[v_it]));
if (!View->testSphere_dirty(spatial->spatial.sphere.P,spatial->spatial.sphere.R)) continue;
if (!View->testSphere_dirty(spatial->GetSpatialData().sphere.P,spatial->GetSpatialData().sphere.R)) continue;

// renderable
IRenderable* renderable = spatial->dcast_Renderable ();
Expand Down
16 changes: 8 additions & 8 deletions src/Layers/xrRenderPC_R1/FStaticRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ extern float r_ssaHZBvsTEX;

ICF bool pred_sp_sort (ISpatial* _1, ISpatial* _2)
{
float d1 = _1->spatial.sphere.P.distance_to_sqr(Device.vCameraPosition);
float d2 = _2->spatial.sphere.P.distance_to_sqr(Device.vCameraPosition);
float d1 = _1->GetSpatialData().sphere.P.distance_to_sqr(Device.vCameraPosition);
float d2 = _2->GetSpatialData().sphere.P.distance_to_sqr(Device.vCameraPosition);
return d1<d2;
}

Expand Down Expand Up @@ -454,20 +454,20 @@ void CRender::Calculate ()
for (u32 o_it=0; o_it<lstRenderables.size(); o_it++)
{
ISpatial* spatial = lstRenderables[o_it]; spatial->spatial_updatesector ();
CSector* sector = (CSector*)spatial->spatial.sector ;
CSector* sector = (CSector*)spatial->GetSpatialData().sector ;
if (0==sector)
continue; // disassociated from S/P structure

// Filter only not light spatial
if (PortalTraverser.i_marker != sector->r_marker && (spatial->spatial.type & STYPE_RENDERABLE) ) continue; // inactive (untouched) sector
if (PortalTraverser.i_marker != sector->r_marker && (spatial->GetSpatialData().type & STYPE_RENDERABLE) ) continue; // inactive (untouched) sector

if (spatial->spatial.type & STYPE_RENDERABLE)
if (spatial->GetSpatialData().type & STYPE_RENDERABLE)
{
for (u32 v_it=0; v_it<sector->r_frustums.size(); v_it++)
{
set_Frustum (&(sector->r_frustums[v_it]));

if (!View->testSphere_dirty(spatial->spatial.sphere.P,spatial->spatial.sphere.R) /*&& (spatial->spatial.type & STYPE_RENDERABLE)*/) continue;
if (!View->testSphere_dirty(spatial->GetSpatialData().sphere.P,spatial->GetSpatialData().sphere.R) /*&& (spatial->spatial.type & STYPE_RENDERABLE)*/) continue;
// renderable
IRenderable* renderable = spatial->dcast_Renderable ();
if (0==renderable) {
Expand Down Expand Up @@ -508,9 +508,9 @@ void CRender::Calculate ()
}
else
{
if ( ViewBase.testSphere_dirty(spatial->spatial.sphere.P,spatial->spatial.sphere.R) )
if ( ViewBase.testSphere_dirty(spatial->GetSpatialData().sphere.P,spatial->GetSpatialData().sphere.R) )
{
VERIFY (spatial->spatial.type & STYPE_LIGHTSOURCE);
VERIFY (spatial->GetSpatialData().type & STYPE_LIGHTSOURCE);
// lightsource
light* L = (light*) spatial->dcast_Light ();
VERIFY (L);
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R1/GlowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


//////////////////////////////////////////////////////////////////////
CGlow::CGlow () : ISpatial(g_SpatialSpace)
CGlow::CGlow () : SpatialBase(g_SpatialSpace)
{
flags.bActive = false;
position.set (0,0,0);
Expand Down Expand Up @@ -77,7 +77,7 @@ void CGlow::set_color (float r, float g, float b) {
void CGlow::spatial_move ()
{
spatial.sphere.set (position,radius);
ISpatial::spatial_move ();
SpatialBase::spatial_move ();
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R1/GlowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "xrCDB/ispatial.h"
#include "xrCDB/xr_collide_defs.h"

class CGlow : public IRender_Glow, public ISpatial
class CGlow : public IRender_Glow, public SpatialBase
{
public:
struct {
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 @@ -79,7 +79,7 @@ void CLightProjector::set_object (IRenderable* O)
if (0==spatial) current= 0;
else {
spatial->spatial_updatesector ();
if (0==spatial->spatial.sector) {
if (0==spatial->GetSpatialData().sector) {
CObject* obj = dynamic_cast<CObject*>(O);
if (obj) Msg ("! Invalid object '%s' position. Outside of sector structure.",obj->cName().c_str());
current = 0;
Expand Down Expand Up @@ -298,7 +298,7 @@ void CLightProjector::calculate ()
ISpatial* spatial = dynamic_cast<ISpatial*> (O);
if (spatial) {
spatial->spatial_updatesector ();
if (spatial->spatial.sector) RImplementation.r_dsgraph_render_R1_box (spatial->spatial.sector,BB,SE_R1_LMODELS);
if (spatial->GetSpatialData().sector) RImplementation.r_dsgraph_render_R1_box (spatial->GetSpatialData().sector,BB,SE_R1_LMODELS);
}
//if (spatial) RImplementation.r_dsgraph_render_subspace (spatial->spatial.sector,mCombine,v_C,FALSE);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R2/r2_R_calculate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ void CRender::Calculate ()
g_SpatialSpace->q_sphere(lstRenderables,0,STYPE_LIGHTSOURCE,Device.vCameraPosition,EPS_L);
for (u32 _it=0; _it<lstRenderables.size(); _it++) {
ISpatial* spatial = lstRenderables[_it]; spatial->spatial_updatesector ();
CSector* sector = (CSector*)spatial->spatial.sector;
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
if (0==sector) continue; // disassociated from S/P structure

VERIFY (spatial->spatial.type & STYPE_LIGHTSOURCE);
VERIFY (spatial->GetSpatialData().type & STYPE_LIGHTSOURCE);
// lightsource
light* L = (light*) (spatial->dcast_Light());
VERIFY (L);
Expand Down
12 changes: 6 additions & 6 deletions src/Layers/xrRenderPC_R2/r2_R_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

IC bool pred_sp_sort (ISpatial* _1, ISpatial* _2)
{
float d1 = _1->spatial.sphere.P.distance_to_sqr (Device.vCameraPosition);
float d2 = _2->spatial.sphere.P.distance_to_sqr (Device.vCameraPosition);
float d1 = _1->GetSpatialData().sphere.P.distance_to_sqr (Device.vCameraPosition);
float d2 = _2->GetSpatialData().sphere.P.distance_to_sqr (Device.vCameraPosition);
return d1<d2 ;
}

Expand Down Expand Up @@ -86,10 +86,10 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
for (u32 o_it=0; o_it<lstRenderables.size(); o_it++)
{
ISpatial* spatial = lstRenderables[o_it]; spatial->spatial_updatesector ();
CSector* sector = (CSector*)spatial->spatial.sector;
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
if (0==sector) continue; // disassociated from S/P structure

if (spatial->spatial.type & STYPE_LIGHTSOURCE) {
if (spatial->GetSpatialData().type & STYPE_LIGHTSOURCE) {
// lightsource
light* L = (light*) (spatial->dcast_Light());
VERIFY (L);
Expand All @@ -104,9 +104,9 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
if (PortalTraverser.i_marker != sector->r_marker) continue; // inactive (untouched) sector
for (u32 v_it=0; v_it<sector->r_frustums.size(); v_it++) {
CFrustum& view = sector->r_frustums[v_it];
if (!view.testSphere_dirty(spatial->spatial.sphere.P,spatial->spatial.sphere.R)) continue;
if (!view.testSphere_dirty(spatial->GetSpatialData().sphere.P,spatial->GetSpatialData().sphere.R)) continue;

if (spatial->spatial.type & STYPE_RENDERABLE)
if (spatial->GetSpatialData().type & STYPE_RENDERABLE)
{
// renderable
IRenderable* renderable = spatial->dcast_Renderable ();
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R3/r2_R_calculate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ void CRender::Calculate ()
g_SpatialSpace->q_sphere(lstRenderables,0,STYPE_LIGHTSOURCE,Device.vCameraPosition,EPS_L);
for (u32 _it=0; _it<lstRenderables.size(); _it++) {
ISpatial* spatial = lstRenderables[_it]; spatial->spatial_updatesector ();
CSector* sector = (CSector*)spatial->spatial.sector;
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
if (0==sector) continue; // disassociated from S/P structure

VERIFY (spatial->spatial.type & STYPE_LIGHTSOURCE);
VERIFY (spatial->GetSpatialData().type & STYPE_LIGHTSOURCE);
// lightsource
light* L = (light*) (spatial->dcast_Light());
VERIFY (L);
Expand Down
12 changes: 6 additions & 6 deletions src/Layers/xrRenderPC_R3/r3_R_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

IC bool pred_sp_sort (ISpatial* _1, ISpatial* _2)
{
float d1 = _1->spatial.sphere.P.distance_to_sqr (Device.vCameraPosition);
float d2 = _2->spatial.sphere.P.distance_to_sqr (Device.vCameraPosition);
float d1 = _1->GetSpatialData().sphere.P.distance_to_sqr (Device.vCameraPosition);
float d2 = _2->GetSpatialData().sphere.P.distance_to_sqr (Device.vCameraPosition);
return d1<d2 ;
}

Expand Down Expand Up @@ -88,10 +88,10 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
for (u32 o_it=0; o_it<lstRenderables.size(); o_it++)
{
ISpatial* spatial = lstRenderables[o_it]; spatial->spatial_updatesector ();
CSector* sector = (CSector*)spatial->spatial.sector;
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
if (0==sector) continue; // disassociated from S/P structure

if (spatial->spatial.type & STYPE_LIGHTSOURCE) {
if (spatial->GetSpatialData().type & STYPE_LIGHTSOURCE) {
// lightsource
light* L = (light*) (spatial->dcast_Light());
VERIFY (L);
Expand All @@ -106,9 +106,9 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
if (PortalTraverser.i_marker != sector->r_marker) continue; // inactive (untouched) sector
for (u32 v_it=0; v_it<sector->r_frustums.size(); v_it++) {
CFrustum& view = sector->r_frustums[v_it];
if (!view.testSphere_dirty(spatial->spatial.sphere.P,spatial->spatial.sphere.R)) continue;
if (!view.testSphere_dirty(spatial->GetSpatialData().sphere.P,spatial->GetSpatialData().sphere.R)) continue;

if (spatial->spatial.type & STYPE_RENDERABLE)
if (spatial->GetSpatialData().type & STYPE_RENDERABLE)
{
// renderable
IRenderable* renderable = spatial->dcast_Renderable ();
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R4/r2_R_calculate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ void CRender::Calculate ()
g_SpatialSpace->q_sphere(lstRenderables,0,STYPE_LIGHTSOURCE,Device.vCameraPosition,EPS_L);
for (u32 _it=0; _it<lstRenderables.size(); _it++) {
ISpatial* spatial = lstRenderables[_it]; spatial->spatial_updatesector ();
CSector* sector = (CSector*)spatial->spatial.sector;
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
if (0==sector) continue; // disassociated from S/P structure

VERIFY (spatial->spatial.type & STYPE_LIGHTSOURCE);
VERIFY (spatial->GetSpatialData().type & STYPE_LIGHTSOURCE);
// lightsource
light* L = (light*) (spatial->dcast_Light());
VERIFY (L);
Expand Down
12 changes: 6 additions & 6 deletions src/Layers/xrRenderPC_R4/r4_R_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

IC bool pred_sp_sort (ISpatial* _1, ISpatial* _2)
{
float d1 = _1->spatial.sphere.P.distance_to_sqr (Device.vCameraPosition);
float d2 = _2->spatial.sphere.P.distance_to_sqr (Device.vCameraPosition);
float d1 = _1->GetSpatialData().sphere.P.distance_to_sqr (Device.vCameraPosition);
float d2 = _2->GetSpatialData().sphere.P.distance_to_sqr (Device.vCameraPosition);
return d1<d2 ;
}

Expand Down Expand Up @@ -89,10 +89,10 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
for (u32 o_it=0; o_it<lstRenderables.size(); o_it++)
{
ISpatial* spatial = lstRenderables[o_it]; spatial->spatial_updatesector ();
CSector* sector = (CSector*)spatial->spatial.sector;
CSector* sector = (CSector*)spatial->GetSpatialData().sector;
if (0==sector) continue; // disassociated from S/P structure

if (spatial->spatial.type & STYPE_LIGHTSOURCE) {
if (spatial->GetSpatialData().type & STYPE_LIGHTSOURCE) {
// lightsource
light* L = (light*) (spatial->dcast_Light());
VERIFY (L);
Expand All @@ -107,9 +107,9 @@ void CRender::render_main (Fmatrix& m_ViewProjection, bool _fportals)
if (PortalTraverser.i_marker != sector->r_marker) continue; // inactive (untouched) sector
for (u32 v_it=0; v_it<sector->r_frustums.size(); v_it++) {
CFrustum& view = sector->r_frustums[v_it];
if (!view.testSphere_dirty(spatial->spatial.sphere.P,spatial->spatial.sphere.R)) continue;
if (!view.testSphere_dirty(spatial->GetSpatialData().sphere.P,spatial->GetSpatialData().sphere.R)) continue;

if (spatial->spatial.type & STYPE_RENDERABLE)
if (spatial->GetSpatialData().type & STYPE_RENDERABLE)
{
// renderable
IRenderable* renderable = spatial->dcast_Renderable ();
Expand Down
Loading

0 comments on commit 8e77ee9

Please sign in to comment.