From eaad5fb2c8f6311d8a2f6bd94b094744e6a7ec21 Mon Sep 17 00:00:00 2001 From: nitrocaster Date: Tue, 10 Nov 2015 17:49:32 +0300 Subject: [PATCH] Convert ICollidable into interface, introduce CollidableBase class. --- src/xrCDB/xr_area_raypick.cpp | 22 ++++++++-------- src/xrEngine/Feel_Vision.cpp | 4 +-- src/xrEngine/ICollidable.cpp | 10 ++++---- src/xrEngine/ICollidable.h | 25 +++++++++++++------ src/xrEngine/xr_collide_form.cpp | 4 +-- src/xrEngine/xr_object.cpp | 12 ++++----- src/xrEngine/xr_object.h | 4 +-- src/xrGame/Actor_Network.cpp | 2 +- src/xrGame/BreakableObject.cpp | 6 ++--- src/xrGame/Car.cpp | 2 +- src/xrGame/CustomZone.cpp | 12 ++++----- src/xrGame/GameObject.cpp | 2 +- src/xrGame/HairsZone.cpp | 2 +- src/xrGame/HangingLamp.cpp | 6 ++--- src/xrGame/Level_bullet_manager_firetrace.cpp | 4 +-- src/xrGame/MosquitoBald.cpp | 4 +-- src/xrGame/PhysicObject.cpp | 6 ++--- src/xrGame/PhysicsShellHolder.cpp | 2 +- src/xrGame/PhysicsSkeletonObject.cpp | 4 +-- src/xrGame/RadioactiveZone.cpp | 8 +++--- src/xrGame/Torch.cpp | 4 +-- src/xrGame/WeaponKnife.cpp | 2 +- src/xrGame/ai/monsters/melee_checker.cpp | 2 +- src/xrGame/base_client_classes_script.cpp | 1 - src/xrGame/level_changer.cpp | 12 ++++----- src/xrGame/script_zone.cpp | 6 ++--- src/xrGame/smart_cover_object.cpp | 10 ++++---- src/xrGame/space_restriction_shape.cpp | 2 +- src/xrGame/space_restrictor.cpp | 10 ++++---- src/xrGame/team_base_zone.cpp | 14 +++++------ 30 files changed, 107 insertions(+), 97 deletions(-) diff --git a/src/xrCDB/xr_area_raypick.cpp b/src/xrCDB/xr_area_raypick.cpp index 46cd3a0914c..dec8c81ad46 100644 --- a/src/xrCDB/xr_area_raypick.cpp +++ b/src/xrCDB/xr_area_raypick.cpp @@ -48,9 +48,9 @@ BOOL CObjectSpace::_RayTest ( const Fvector &start, const Fvector &dir, float ra ISpatial* spatial = r_spatial[o_it]; CObject* collidable = spatial->dcast_CObject (); if (collidable && (collidable!=ignore_object)) { - ECollisionFormType tp = collidable->collidable.model->Type(); - if ((tgt&(rqtObject|rqtObstacle))&&(tp==cftObject)&&collidable->collidable.model->_RayQuery(Q,r_temp)) return TRUE; - if ((tgt&rqtShape)&&(tp==cftShape)&&collidable->collidable.model->_RayQuery(Q,r_temp)) return TRUE; + ECollisionFormType tp = collidable->GetCForm()->Type(); + if ((tgt&(rqtObject|rqtObstacle))&&(tp==cftObject)&&collidable->GetCForm()->_RayQuery(Q,r_temp)) return TRUE; + if ((tgt&rqtShape)&&(tp==cftShape)&&collidable->GetCForm()->_RayQuery(Q,r_temp)) return TRUE; } } } @@ -128,11 +128,11 @@ BOOL CObjectSpace::_RayPick ( const Fvector &start, const Fvector &dir, float ra CObject* collidable = spatial->dcast_CObject(); if (0==collidable) continue; if (collidable==ignore_object) continue; - ECollisionFormType tp = collidable->collidable.model->Type(); + ECollisionFormType tp = collidable->GetCForm()->Type(); if (((tgt&(rqtObject|rqtObstacle))&&(tp==cftObject))||((tgt&rqtShape)&&(tp==cftShape))){ u32 C = color_xrgb (64,64,64); Q.range = R.range; - if (collidable->collidable.model->_RayQuery(Q,r_temp)){ + if (collidable->GetCForm()->_RayQuery(Q,r_temp)){ C = color_xrgb(128,128,196); R.set_if_less (r_temp.r_begin()); } @@ -191,8 +191,8 @@ BOOL CObjectSpace::_RayQuery2 (collide::rq_results& r_dest, const collide::ray_d CObject* collidable = r_spatial[o_it]->dcast_CObject(); if (0==collidable) continue; if (collidable==ignore_object) continue; - ICollisionForm* cform = collidable->collidable.model; - ECollisionFormType tp = collidable->collidable.model->Type(); + ICollisionForm* cform = collidable->GetCForm(); + ECollisionFormType tp = cform->Type(); if (((R.tgt&(rqtObject|rqtObstacle))&&(tp==cftObject))||((R.tgt&rqtShape)&&(tp==cftShape))){ if (tb&&!tb(R,collidable,user_data))continue; cform->_RayQuery(R,r_temp); @@ -258,8 +258,8 @@ BOOL CObjectSpace::_RayQuery3 (collide::rq_results& r_dest, const collide::ray_d CObject* collidable = r_spatial[o_it]->dcast_CObject(); if (0==collidable) continue; if (collidable==ignore_object) continue; - ICollisionForm* cform = collidable->collidable.model; - ECollisionFormType tp = collidable->collidable.model->Type(); + ICollisionForm* cform = collidable->GetCForm(); + ECollisionFormType tp = cform->Type(); if (((R.tgt&(rqtObject|rqtObstacle))&&(tp==cftObject))||((R.tgt&rqtShape)&&(tp==cftShape))){ if (tb&&!tb(d_rd,collidable,user_data))continue; u32 r_cnt = r_temp.r_count(); @@ -345,8 +345,8 @@ BOOL CObjectSpace::_RayQuery (collide::rq_results& r_dest, const collide::ray_de CObject* collidable = r_spatial[o_it]->dcast_CObject(); if (0==collidable) continue; if (collidable==ignore_object) continue; - ICollisionForm* cform = collidable->collidable.model; - ECollisionFormType tp = collidable->collidable.model->Type(); + ICollisionForm* cform = collidable->GetCForm(); + ECollisionFormType tp = cform->Type(); if (((R.tgt&(rqtObject|rqtObstacle))&&(tp==cftObject))||((R.tgt&rqtShape)&&(tp==cftShape))){ if (tb&&!tb(d_rd,collidable,user_data))continue; cform->_RayQuery(d_rd,r_temp); diff --git a/src/xrEngine/Feel_Vision.cpp b/src/xrEngine/Feel_Vision.cpp index d550a2ad933..6bdd4d2bc75 100644 --- a/src/xrEngine/Feel_Vision.cpp +++ b/src/xrEngine/Feel_Vision.cpp @@ -161,7 +161,7 @@ void Vision::o_trace(Fvector& P, float dt, float vis_threshold) xr_vector::iterator I = feel_visible.begin(), E = feel_visible.end(); for (; I != E; I++) { - if (0 == I->O->CFORM()) { I->fuzzy = -1; continue; } + if (0 == I->O->GetCForm()) { I->fuzzy = -1; continue; } // verify relation // if (positive(I->fuzzy) && I->O->Position().similar(I->cp_LR_dst,lr_granularity) && P.similar(I->cp_LR_src,lr_granularity)) @@ -240,7 +240,7 @@ void Vision::o_trace(Fvector& P, float dt, float vis_threshold) CObject const* object = (*i)->dcast_CObject(); RQR.r_clear(); - if (object && object->collidable.model && !object->collidable.model->_RayQuery(RD, RQR)) + if (object && object->GetCForm() && !object->GetCForm()->_RayQuery(RD, RQR)) continue; collision_found = true; diff --git a/src/xrEngine/ICollidable.cpp b/src/xrEngine/ICollidable.cpp index 320ef4e1fc0..11a94d7b96f 100644 --- a/src/xrEngine/ICollidable.cpp +++ b/src/xrEngine/ICollidable.cpp @@ -2,14 +2,14 @@ #include "xrCDB/ispatial.h" #include "icollidable.h" #include "xr_collide_form.h" - -ICollidable::ICollidable() +// XXX: rename this file to CollidableBase.cpp +CollidableBase::CollidableBase() { - collidable.model = NULL; + CForm = nullptr; ISpatial* self = dynamic_cast (this); if (self) self->spatial.type |= STYPE_COLLIDEABLE; }; -ICollidable::~ICollidable() +CollidableBase::~CollidableBase() { - xr_delete(collidable.model); + xr_delete(CForm); }; diff --git a/src/xrEngine/ICollidable.h b/src/xrEngine/ICollidable.h index 936b42a47da..082530f4429 100644 --- a/src/xrEngine/ICollidable.h +++ b/src/xrEngine/ICollidable.h @@ -2,14 +2,25 @@ class ENGINE_API ICollisionForm; -class ENGINE_API ICollidable +class ICollidable { public: - struct - { - ICollisionForm* model; - } collidable; + virtual ~ICollidable() = 0; + virtual void SetCForm(ICollisionForm *cform) = 0; + virtual ICollisionForm *GetCForm() const = 0; +}; + +inline ICollidable::~ICollidable() {} + +class ENGINE_API CollidableBase : public ICollidable +{ public: - ICollidable(); - virtual ~ICollidable(); + CollidableBase(); + virtual ~CollidableBase(); + + virtual void SetCForm(ICollisionForm *cform) override { CForm = cform; } + virtual ICollisionForm *GetCForm() const override { return CForm; } + +protected: + ICollisionForm *CForm; }; diff --git a/src/xrEngine/xr_collide_form.cpp b/src/xrEngine/xr_collide_form.cpp index ee1ef17b5ba..434468c63ac 100644 --- a/src/xrEngine/xr_collide_form.cpp +++ b/src/xrEngine/xr_collide_form.cpp @@ -487,9 +487,9 @@ BOOL CCF_Shape::Contact(CObject* O) O->Center(S.P); S.R = O->Radius(); } - else if (O->CFORM()) + else if (O->GetCForm()) { - S = O->CFORM()->getSphere(); + S = O->GetCForm()->getSphere(); O->XFORM().transform_tiny(S.P); } else return FALSE; diff --git a/src/xrEngine/xr_object.cpp b/src/xrEngine/xr_object.cpp index 9e3422bb9d5..47b8442416a 100644 --- a/src/xrEngine/xr_object.cpp +++ b/src/xrEngine/xr_object.cpp @@ -122,7 +122,7 @@ void CObject::setEnabled(BOOL _enabled) if (_enabled) { Props.bEnabled = 1; - if (collidable.model) spatial.type |= STYPE_COLLIDEABLE; + if (CForm) spatial.type |= STYPE_COLLIDEABLE; } else { @@ -212,12 +212,12 @@ BOOL CObject::net_Spawn(CSE_Abstract* data) if (0 == Visual() && pSettings->line_exist(cNameSect(), "visual")) cNameVisual_set(pSettings->r_string(cNameSect(), "visual")); - if (0 == collidable.model) + if (0 == CForm) { if (pSettings->line_exist(cNameSect(), "cform")) { VERIFY3(*NameVisual, "Model isn't assigned for object, but cform requisted", *cName()); - collidable.model = xr_new(this); + CForm = xr_new(this); } } @@ -239,7 +239,7 @@ BOOL CObject::net_Spawn(CSE_Abstract* data) void CObject::net_Destroy() { VERIFY(getDestroy()); - xr_delete(collidable.model); + xr_delete(CForm); if (register_schedule()) shedule_unregister(); @@ -323,7 +323,7 @@ void CObject::UpdateCL() if (Parent && spatial.node_ptr) Debug.fatal(DEBUG_INFO, "Object %s has parent but is still registered inside spatial DB", *cName()); - if ((0 == collidable.model) && (spatial.type&STYPE_COLLIDEABLE)) Debug.fatal(DEBUG_INFO, "Object %s registered as 'collidable' but has no collidable model", *cName()); + if ((0 == CForm) && (spatial.type&STYPE_COLLIDEABLE)) Debug.fatal(DEBUG_INFO, "Object %s registered as 'collidable' but has no collidable model", *cName()); #endif spatial_update(base_spu_epsP * 5, base_spu_epsR * 5); @@ -462,7 +462,7 @@ Fvector CObject::get_last_local_point_on_mesh(Fvector const& local_point, u16 co // Fetch data Fmatrix mE; const Fmatrix& M = XFORM(); - const Fbox& B = CFORM()->getBBox(); + const Fbox& B = CForm->getBBox(); // Build OBB + Ellipse and X-form point Fvector c, r; diff --git a/src/xrEngine/xr_object.h b/src/xrEngine/xr_object.h index 0b01d9701e9..97a0cc7b84a 100644 --- a/src/xrEngine/xr_object.h +++ b/src/xrEngine/xr_object.h @@ -22,6 +22,7 @@ class CSE_Abstract; //----------------------------------------------------------------------------------------------------------- // CObject //----------------------------------------------------------------------------------------------------------- + class IPhysicsShell; xr_pure_interface IObjectPhysicsCollision; #pragma pack(push,4) @@ -30,7 +31,7 @@ class ENGINE_API CObject : public ISpatial, public ISheduled, public IRenderable, - public ICollidable + public CollidableBase { public: struct SavedPosition @@ -130,7 +131,6 @@ class ENGINE_API CObject : // Accessors and converters ICF IRenderVisual* Visual() const { return renderable.visual; } - ICF ICollisionForm* CFORM() const { return collidable.model; } virtual CObject* dcast_CObject() { return this; } virtual IRenderable* dcast_Renderable() { return this; } virtual void OnChangeVisual() { } diff --git a/src/xrGame/Actor_Network.cpp b/src/xrGame/Actor_Network.cpp index 2e42468fb81..6c6e29784c8 100644 --- a/src/xrGame/Actor_Network.cpp +++ b/src/xrGame/Actor_Network.cpp @@ -1477,7 +1477,7 @@ void CActor::OnRender_Network() Level().debug_renderer().draw_obb(BoneMatrix, BoneOBB.m_halfsize, color_rgba(0, 255, 0, 255)); }; */ - CCF_Skeleton* Skeleton = smart_cast(collidable.model); + CCF_Skeleton* Skeleton = smart_cast(CForm); if (Skeleton){ Skeleton->_dbg_refresh(); diff --git a/src/xrGame/BreakableObject.cpp b/src/xrGame/BreakableObject.cpp index 5753d2d82fe..20d0bb1fa76 100644 --- a/src/xrGame/BreakableObject.cpp +++ b/src/xrGame/BreakableObject.cpp @@ -43,8 +43,8 @@ BOOL CBreakableObject::net_Spawn(CSE_Abstract* DC) CSE_ALifeObjectBreakable *obj = smart_cast(e); R_ASSERT (obj); inherited::net_Spawn (DC); - VERIFY(!collidable.model); - collidable.model = xr_new(this); + VERIFY(!CForm); + CForm = xr_new(this); // set bone id R_ASSERT (Visual()&&smart_cast(Visual())); // IKinematics* K = smart_cast(Visual()); @@ -198,7 +198,7 @@ void CBreakableObject::net_Destroy() m_pPhysicsShell=NULL; inherited::net_Destroy(); - xr_delete(collidable.model); + xr_delete(CForm); Init(); //Visual()->vis.box.set(m_saved_box); GlobalEnv.Render->model_Delete(renderable.visual,TRUE); diff --git a/src/xrGame/Car.cpp b/src/xrGame/Car.cpp index 486d2b63b3a..bbc7fe136f5 100644 --- a/src/xrGame/Car.cpp +++ b/src/xrGame/Car.cpp @@ -1463,7 +1463,7 @@ bool CCar::Use(const Fvector& pos,const Fvector& dir,const Fvector& foot_pos) RQR.r_clear (); collide::ray_defs Q(pos, dir, 3.f, CDB::OPT_CULL,collide::rqtObject); // CDB::OPT_ONLYFIRST CDB::OPT_ONLYNEAREST VERIFY(!fis_zero(Q.dir.square_magnitude())); - if (g_pGameLevel->ObjectSpace.RayQuery(RQR,collidable.model,Q)) + if (g_pGameLevel->ObjectSpace.RayQuery(RQR,CForm,Q)) { collide::rq_results& R = RQR; int y=R.r_count(); diff --git a/src/xrGame/CustomZone.cpp b/src/xrGame/CustomZone.cpp index 2d45d9e38a5..7cb3b31207c 100644 --- a/src/xrGame/CustomZone.cpp +++ b/src/xrGame/CustomZone.cpp @@ -496,7 +496,7 @@ void CCustomZone::shedule_Update(u32 dt) if (IsEnabled()) { - const Fsphere& s = CFORM()->getSphere(); + const Fsphere& s = GetCForm()->getSphere(); Fvector P; XFORM().transform_tiny (P,s.P); @@ -633,7 +633,7 @@ bool CCustomZone::feel_touch_contact(CObject* O) if (!object || !object->IsVisibleForZones()) return (FALSE); - if (!((CCF_Shape*)CFORM())->Contact(O)) + if (!((CCF_Shape*)GetCForm())->Contact(O)) return (FALSE); return (object->feel_touch_on_contact(this)); @@ -828,7 +828,7 @@ void CCustomZone::PlayEntranceParticles(CGameObject* pObject) void CCustomZone::PlayBoltEntranceParticles() { - CCF_Shape* Sh = (CCF_Shape*)CFORM(); + CCF_Shape* Sh = (CCF_Shape*)GetCForm(); const Fmatrix& XF = XFORM(); Fmatrix PXF; xr_vector& Shapes = Sh->Shapes(); @@ -1410,11 +1410,11 @@ BOOL CCustomZone::AlwaysTheCrow() void CCustomZone::CalcDistanceTo(const Fvector& P, float& dist, float& radius) { - R_ASSERT (CFORM()->Type()==cftShape); - CCF_Shape* Sh = (CCF_Shape*)CFORM(); + R_ASSERT (GetCForm()->Type()==cftShape); + CCF_Shape* Sh = (CCF_Shape*)GetCForm(); dist = P.distance_to(Position()); - float sr = CFORM()->getSphere().R; + float sr = GetCForm()->getSphere().R; //quick test if(Sh->Shapes().size()==1) { diff --git a/src/xrGame/GameObject.cpp b/src/xrGame/GameObject.cpp index 97b169ab42c..ebce65ef66f 100644 --- a/src/xrGame/GameObject.cpp +++ b/src/xrGame/GameObject.cpp @@ -649,7 +649,7 @@ void CGameObject::spatial_move () #ifdef DEBUG void CGameObject::dbg_DrawSkeleton () { - CCF_Skeleton* Skeleton = smart_cast(collidable.model); + CCF_Skeleton* Skeleton = smart_cast(CForm); if (!Skeleton) return; Skeleton->_dbg_refresh(); diff --git a/src/xrGame/HairsZone.cpp b/src/xrGame/HairsZone.cpp index 81604522c32..c637d47804d 100644 --- a/src/xrGame/HairsZone.cpp +++ b/src/xrGame/HairsZone.cpp @@ -47,7 +47,7 @@ void CHairsZone::Affect(SZoneObjectInfo* O) if(O->zone_ignore) return; Fvector P; - XFORM().transform_tiny(P,CFORM()->getSphere().P); + XFORM().transform_tiny(P, GetCForm()->getSphere().P); Fvector hit_dir; hit_dir.set(::Random.randF(-.5f,.5f), diff --git a/src/xrGame/HangingLamp.cpp b/src/xrGame/HangingLamp.cpp index c1014fe744b..605e1e002ff 100644 --- a/src/xrGame/HangingLamp.cpp +++ b/src/xrGame/HangingLamp.cpp @@ -89,13 +89,13 @@ BOOL CHangingLamp::net_Spawn(CSE_Abstract* DC) // set bone id // CInifile* pUserData = K->LL_UserData(); // R_ASSERT3 (pUserData,"Empty HangingLamp user data!",lamp->get_visual()); - xr_delete(collidable.model); + xr_delete(CForm); if (Visual()){ IKinematics* K = smart_cast(Visual()); R_ASSERT (Visual()&&smart_cast(Visual())); light_bone = K->LL_BoneID (*lamp->light_main_bone); VERIFY(light_bone!=BI_NONE); ambient_bone = K->LL_BoneID (*lamp->light_ambient_bone);VERIFY(ambient_bone!=BI_NONE); - collidable.model = xr_new (this); + CForm = xr_new (this); } fBrightness = lamp->brightness; clr.set (lamp->color); clr.a = 1.f; @@ -154,7 +154,7 @@ BOOL CHangingLamp::net_Spawn(CSE_Abstract* DC) } setVisible ((BOOL)!!Visual()); - setEnabled ((BOOL)!!collidable.model); + setEnabled ((BOOL)!!CForm); return (TRUE); } diff --git a/src/xrGame/Level_bullet_manager_firetrace.cpp b/src/xrGame/Level_bullet_manager_firetrace.cpp index f2bf83e9151..d78d84ba393 100644 --- a/src/xrGame/Level_bullet_manager_firetrace.cpp +++ b/src/xrGame/Level_bullet_manager_firetrace.cpp @@ -47,7 +47,7 @@ BOOL CBulletManager::test_callback(const collide::ray_defs& rd, CObject* object, if (object){ CEntity* entity = smart_cast(object); if (entity&&entity->g_Alive()&&(entity->ID()!=bullet->parent_id)){ - ICollisionForm* cform = entity->collidable.model; + ICollisionForm* cform = entity->GetCForm(); if ((NULL!=cform) && (cftObject==cform->Type())){ CActor* actor = smart_cast(entity); CAI_Stalker* stalker= smart_cast(entity); @@ -357,7 +357,7 @@ bool CBulletManager::ObjectHit( SBullet_Hit* hit_res, SBullet* bullet, const Fve if ( R.O ) { //вернуть нормаль по которой играть партиклы - CCF_Skeleton* skeleton = smart_cast(R.O->CFORM()); + CCF_Skeleton* skeleton = smart_cast(R.O->GetCForm()); if ( skeleton ) { Fvector e_center; diff --git a/src/xrGame/MosquitoBald.cpp b/src/xrGame/MosquitoBald.cpp index c62f439df3e..9f8fc18a3de 100644 --- a/src/xrGame/MosquitoBald.cpp +++ b/src/xrGame/MosquitoBald.cpp @@ -54,7 +54,7 @@ void CMosquitoBald::Affect(SZoneObjectInfo* O) if(O->zone_ignore) return; Fvector P; - XFORM().transform_tiny(P,CFORM()->getSphere().P); + XFORM().transform_tiny(P, GetCForm()->getSphere().P); Fvector hit_dir; hit_dir.set( ::Random.randF(-.5f,.5f), @@ -97,7 +97,7 @@ void CMosquitoBald::UpdateSecondaryHit() if((&(*it))->zone_ignore) return; Fvector P; - XFORM().transform_tiny(P,CFORM()->getSphere().P); + XFORM().transform_tiny(P, GetCForm()->getSphere().P); Fvector hit_dir; hit_dir.set( ::Random.randF(-.5f,.5f), diff --git a/src/xrGame/PhysicObject.cpp b/src/xrGame/PhysicObject.cpp index cbb166f7451..f7b20824928 100644 --- a/src/xrGame/PhysicObject.cpp +++ b/src/xrGame/PhysicObject.cpp @@ -90,7 +90,7 @@ if(dbg_draw_doors) } void CPhysicObject::create_collision_model ( ) { - xr_delete( collidable.model ); + xr_delete(CForm); VERIFY( Visual() ); IKinematics *K = Visual()->dcast_PKinematics (); @@ -99,11 +99,11 @@ void CPhysicObject::create_collision_model ( ) CInifile* ini = K->LL_UserData(); if( ini && ini->section_exist( "collide" ) && ini->line_exist("collide", "mesh" ) && ini->r_bool("collide", "mesh" ) ) { - collidable.model = xr_new( this ); + CForm = xr_new( this ); return; } - collidable.model = xr_new(this); + CForm = xr_new(this); /* switch(m_type) { diff --git a/src/xrGame/PhysicsShellHolder.cpp b/src/xrGame/PhysicsShellHolder.cpp index ce039754f0e..1abb7376b7f 100644 --- a/src/xrGame/PhysicsShellHolder.cpp +++ b/src/xrGame/PhysicsShellHolder.cpp @@ -516,7 +516,7 @@ u16 CPhysicsShellHolder::ObjectID()const } ICollisionForm* CPhysicsShellHolder::ObjectCollisionModel() { - return collidable.model; + return CForm; // XXX: use ICollidable::GetCForm() instead } IKinematics *CPhysicsShellHolder::ObjectKinematics() diff --git a/src/xrGame/PhysicsSkeletonObject.cpp b/src/xrGame/PhysicsSkeletonObject.cpp index ed2fceb3368..1ac878efac8 100644 --- a/src/xrGame/PhysicsSkeletonObject.cpp +++ b/src/xrGame/PhysicsSkeletonObject.cpp @@ -23,8 +23,8 @@ BOOL CPhysicsSkeletonObject::net_Spawn(CSE_Abstract* DC) CSE_Abstract *e = (CSE_Abstract*)(DC); inherited::net_Spawn (DC); - xr_delete(collidable.model); - collidable.model = xr_new(this); + xr_delete(CForm); + CForm = xr_new(this); CPHSkeleton::Spawn(e); setVisible(TRUE); setEnabled(TRUE); diff --git a/src/xrGame/RadioactiveZone.cpp b/src/xrGame/RadioactiveZone.cpp index 9cbe5ad439c..890fd5c159b 100644 --- a/src/xrGame/RadioactiveZone.cpp +++ b/src/xrGame/RadioactiveZone.cpp @@ -37,7 +37,7 @@ void CRadioactiveZone::Affect(SZoneObjectInfo* O) clamp (O->f_time_affected, tg-(one*3), tg); Fvector pos; - XFORM().transform_tiny (pos,CFORM()->getSphere().P); + XFORM().transform_tiny (pos, GetCForm()->getSphere().P); Fvector dir ={0,0,0}; float power = Power(O->object->Position().distance_to(pos),nearest_shape_radius(O)); @@ -94,7 +94,7 @@ bool CRadioactiveZone::feel_touch_contact(CObject* O) CActor* A = smart_cast(O); if ( A ) { - if (!((CCF_Shape*)CFORM())->Contact(O)) return false; + if (!((CCF_Shape*)GetCForm())->Contact(O)) return false; return A->feel_touch_on_contact(this); }else return false; @@ -106,7 +106,7 @@ void CRadioactiveZone::UpdateWorkload (u32 dt) { OBJECT_INFO_VEC_IT it; Fvector pos; - XFORM().transform_tiny(pos,CFORM()->getSphere().P); + XFORM().transform_tiny(pos, GetCForm()->getSphere().P); for(it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it) { if( !(*it).object->getDestroy() && smart_cast((*it).object)) @@ -142,7 +142,7 @@ void CRadioactiveZone::UpdateWorkload (u32 dt) float CRadioactiveZone::nearest_shape_radius(SZoneObjectInfo* O) { - CCF_Shape* Sh = (CCF_Shape*)CFORM(); + CCF_Shape* Sh = (CCF_Shape*)GetCForm(); if(Sh->Shapes().size()==1) { diff --git a/src/xrGame/Torch.cpp b/src/xrGame/Torch.cpp index 6921784f025..f62b7b2a07c 100644 --- a/src/xrGame/Torch.cpp +++ b/src/xrGame/Torch.cpp @@ -203,9 +203,9 @@ BOOL CTorch::net_Spawn(CSE_Abstract* DC) R_ASSERT (torch); cNameVisual_set (torch->get_visual()); - R_ASSERT (!CFORM()); + R_ASSERT (!GetCForm()); R_ASSERT (smart_cast(Visual())); - collidable.model = xr_new (this); + CForm = xr_new (this); if (!inherited::net_Spawn(DC)) return (FALSE); diff --git a/src/xrGame/WeaponKnife.cpp b/src/xrGame/WeaponKnife.cpp index e65bd9262be..12b28384f69 100644 --- a/src/xrGame/WeaponKnife.cpp +++ b/src/xrGame/WeaponKnife.cpp @@ -567,7 +567,7 @@ void CWeaponKnife::fill_shapes_list(CEntityAlive const * entity, if (!entity) return; - CCF_Skeleton* tmp_skeleton = smart_cast(entity->CFORM()); + CCF_Skeleton* tmp_skeleton = smart_cast(entity->GetCForm()); if (!tmp_skeleton) return; diff --git a/src/xrGame/ai/monsters/melee_checker.cpp b/src/xrGame/ai/monsters/melee_checker.cpp index defc9c610e7..addda1f0bd9 100644 --- a/src/xrGame/ai/monsters/melee_checker.cpp +++ b/src/xrGame/ai/monsters/melee_checker.cpp @@ -23,7 +23,7 @@ float CMeleeChecker::distance_to_enemy(const CEntityAlive *enemy) collide::ray_defs r_query (my_head_pos, dir, MAX_TRACE_ENEMY_RANGE, CDB::OPT_CULL | CDB::OPT_ONLYNEAREST, collide::rqtObject); r_res.r_clear (); - if (m_object->CFORM()->_RayQuery(r_query, r_res)) { + if (m_object->GetCForm()->_RayQuery(r_query, r_res)) { if (r_res.r_begin()->O == enemy) dist = r_res.r_begin()->range; } diff --git a/src/xrGame/base_client_classes_script.cpp b/src/xrGame/base_client_classes_script.cpp index 9e048ab9dd5..8c0664a053e 100644 --- a/src/xrGame/base_client_classes_script.cpp +++ b/src/xrGame/base_client_classes_script.cpp @@ -74,7 +74,6 @@ SCRIPT_EXPORT(ICollidable, (), module(luaState) [ class_("ICollidable") - .def(constructor<>()) ]; }); diff --git a/src/xrGame/level_changer.cpp b/src/xrGame/level_changer.cpp index b082daee684..f8984656c3f 100644 --- a/src/xrGame/level_changer.cpp +++ b/src/xrGame/level_changer.cpp @@ -28,12 +28,12 @@ CLevelChanger::~CLevelChanger () void CLevelChanger::Center (Fvector& C) const { - XFORM().transform_tiny (C,CFORM()->getSphere().P); + XFORM().transform_tiny (C, GetCForm()->getSphere().P); } float CLevelChanger::Radius () const { - return CFORM()->getRadius (); + return GetCForm()->getRadius (); } void CLevelChanger::net_Destroy () @@ -51,7 +51,7 @@ BOOL CLevelChanger::net_Spawn (CSE_Abstract* DC) m_b_enabled = true; m_invite_str = DEF_INVITATION; CCF_Shape *l_pShape = xr_new(this); - collidable.model = l_pShape; + SetCForm(l_pShape); CSE_Abstract *l_tpAbstract = (CSE_Abstract*)(DC); CSE_ALifeLevelChanger *l_tpALifeLevelChanger = smart_cast(l_tpAbstract); @@ -89,7 +89,7 @@ BOOL CLevelChanger::net_Spawn (CSE_Abstract* DC) if (bOk) { l_pShape->ComputeBounds (); Fvector P; - XFORM().transform_tiny (P,CFORM()->getSphere().P); + XFORM().transform_tiny (P, GetCForm()->getSphere().P); setEnabled (TRUE); } g_lchangers.push_back (this); @@ -100,7 +100,7 @@ void CLevelChanger::shedule_Update(u32 dt) { inherited::shedule_Update (dt); - const Fsphere &s = CFORM()->getSphere(); + const Fsphere &s = GetCForm()->getSphere(); Fvector P; XFORM().transform_tiny (P,s.P); feel_touch_update (P,s.R); @@ -164,7 +164,7 @@ bool CLevelChanger::get_reject_pos(Fvector& p, Fvector& r) bool CLevelChanger::feel_touch_contact (CObject *object) { - bool bRes = (((CCF_Shape*)CFORM())->Contact(object)); + bool bRes = (((CCF_Shape*)GetCForm())->Contact(object)); bRes = bRes && smart_cast(object) && smart_cast(object)->g_Alive(); return bRes; } diff --git a/src/xrGame/script_zone.cpp b/src/xrGame/script_zone.cpp index f33338abed0..75715bccf0b 100644 --- a/src/xrGame/script_zone.cpp +++ b/src/xrGame/script_zone.cpp @@ -51,7 +51,7 @@ void CScriptZone::shedule_Update(u32 dt) { inherited::shedule_Update (dt); - const Fsphere &s = CFORM()->getSphere(); + const Fsphere &s = GetCForm()->getSphere(); Fvector P; XFORM().transform_tiny (P,s.P); feel_touch_update (P,s.R); @@ -90,7 +90,7 @@ void CScriptZone::net_Relcase (CObject *O) bool CScriptZone::feel_touch_contact (CObject* O) { - return (((CCF_Shape*)CFORM())->Contact(O)); + return (((CCF_Shape*)GetCForm())->Contact(O)); } #ifdef DEBUG @@ -101,7 +101,7 @@ void CScriptZone::OnRender() //RCache.OnFrameEnd(); Fvector l_half; l_half.set(.5f, .5f, .5f); Fmatrix l_ball, l_box; - xr_vector &l_shapes = ((CCF_Shape*)CFORM())->Shapes(); + xr_vector &l_shapes = ((CCF_Shape*)GetCForm())->Shapes(); xr_vector::iterator l_pShape; for(l_pShape = l_shapes.begin(); l_shapes.end() != l_pShape; ++l_pShape) diff --git a/src/xrGame/smart_cover_object.cpp b/src/xrGame/smart_cover_object.cpp index dbeabc92579..e312045a5e9 100644 --- a/src/xrGame/smart_cover_object.cpp +++ b/src/xrGame/smart_cover_object.cpp @@ -37,7 +37,7 @@ BOOL object::net_Spawn (CSE_Abstract *server_entity) Msg ("! smart cover %s has no description", smart_cover->name_replace()); CCF_Shape *shape = xr_new(this); - collidable.model = shape; + SetCForm(shape); typedef CShapeData::ShapeVec ShapeVec; ShapeVec::iterator I = smart_cover->shapes.begin(); @@ -77,12 +77,12 @@ BOOL object::net_Spawn (CSE_Abstract *server_entity) void object::Center (Fvector &result) const { - XFORM().transform_tiny (result,CFORM()->getSphere().P); + XFORM().transform_tiny (result, GetCForm()->getSphere().P); } float object::Radius () const { - return (CFORM()->getRadius()); + return (GetCForm()->getRadius()); } void object::UpdateCL () @@ -106,7 +106,7 @@ void object::OnRender () u32 Color = color_xrgb(0,255,0); typedef xr_vector Shapes; - Shapes &l_shapes = ((CCF_Shape*)CFORM())->Shapes(); + Shapes &l_shapes = ((CCF_Shape*)GetCForm())->Shapes(); Shapes::iterator l_pShape; CDebugRenderer &renderer = Level().debug_renderer(); for (l_pShape = l_shapes.begin(); l_shapes.end() != l_pShape; ++l_pShape) { @@ -152,7 +152,7 @@ void object::OnRender () bool object::inside (Fvector const &position) const { - CCF_Shape *shape = static_cast(collidable.model); + CCF_Shape *shape = static_cast(GetCForm()); VERIFY (shape); typedef xr_vector Shapes; diff --git a/src/xrGame/space_restriction_shape.cpp b/src/xrGame/space_restriction_shape.cpp index ee6283b8a01..cbdcf70e3cf 100644 --- a/src/xrGame/space_restriction_shape.cpp +++ b/src/xrGame/space_restriction_shape.cpp @@ -102,7 +102,7 @@ void CSpaceRestrictionShape::fill_shape (const CCF_Shape::shape_def &shape) void CSpaceRestrictionShape::build_border () { m_border.clear (); - CCF_Shape *shape = smart_cast(m_restrictor->collidable.model); + CCF_Shape *shape = smart_cast(m_restrictor->GetCForm()); VERIFY (shape); xr_vector::const_iterator I = shape->Shapes().begin(); xr_vector::const_iterator E = shape->Shapes().end(); diff --git a/src/xrGame/space_restrictor.cpp b/src/xrGame/space_restrictor.cpp index b63655db123..e4ceeca0401 100644 --- a/src/xrGame/space_restrictor.cpp +++ b/src/xrGame/space_restrictor.cpp @@ -25,12 +25,12 @@ CSpaceRestrictor::~CSpaceRestrictor () void CSpaceRestrictor::Center (Fvector& C) const { - XFORM().transform_tiny (C,CFORM()->getSphere().P); + XFORM().transform_tiny (C, GetCForm()->getSphere().P); } float CSpaceRestrictor::Radius () const { - return (CFORM()->getRadius()); + return (GetCForm()->getRadius()); } BOOL CSpaceRestrictor::net_Spawn (CSE_Abstract* data) @@ -44,7 +44,7 @@ BOOL CSpaceRestrictor::net_Spawn (CSE_Abstract* data) m_space_restrictor_type = se_shape->m_space_restrictor_type; CCF_Shape *shape = xr_new(this); - collidable.model = shape; + SetCForm(shape); for (u32 i=0; i < se_shape->shapes.size(); ++i) { CShapeData::shape_def &S = se_shape->shapes[i]; @@ -123,7 +123,7 @@ void CSpaceRestrictor::prepare () const m_spheres.resize (0); m_boxes.resize (0); - const CCF_Shape *shape = (const CCF_Shape*)collidable.model; + const CCF_Shape *shape = (const CCF_Shape*)GetCForm(); typedef xr_vector SHAPES; @@ -216,7 +216,7 @@ void CSpaceRestrictor::OnRender () GlobalEnv.DRender->OnFrameEnd(); Fvector l_half; l_half.set(.5f, .5f, .5f); Fmatrix l_ball, l_box; - xr_vector &l_shapes = ((CCF_Shape*)CFORM())->Shapes(); + xr_vector &l_shapes = ((CCF_Shape*)GetCForm())->Shapes(); xr_vector::iterator l_pShape; u32 Color = 0; diff --git a/src/xrGame/team_base_zone.cpp b/src/xrGame/team_base_zone.cpp index 1f7ea4556ad..fc4b34a8b51 100644 --- a/src/xrGame/team_base_zone.cpp +++ b/src/xrGame/team_base_zone.cpp @@ -37,18 +37,18 @@ void CTeamBaseZone::reinit () void CTeamBaseZone::Center (Fvector &C) const { - XFORM().transform_tiny (C,CFORM()->getSphere().P); + XFORM().transform_tiny (C, GetCForm()->getSphere().P); } float CTeamBaseZone::Radius () const { - return (CFORM()->getRadius()); + return (GetCForm()->getRadius()); } BOOL CTeamBaseZone::net_Spawn (CSE_Abstract* DC) { CCF_Shape *l_pShape = xr_new(this); - collidable.model = l_pShape; + SetCForm(l_pShape); CSE_Abstract *l_tpAbstract = (CSE_Abstract*)(DC); CSE_ALifeTeamBaseZone *l_tpALifeScriptZone = smart_cast(l_tpAbstract); @@ -76,7 +76,7 @@ BOOL CTeamBaseZone::net_Spawn (CSE_Abstract* DC) if (bOk) { l_pShape->ComputeBounds (); Fvector P; - XFORM().transform_tiny (P,CFORM()->getSphere().P); + XFORM().transform_tiny (P, GetCForm()->getSphere().P); setEnabled (TRUE); } @@ -103,7 +103,7 @@ void CTeamBaseZone::shedule_Update(u32 dt) { inherited::shedule_Update (dt); - const Fsphere &s = CFORM()->getSphere(); + const Fsphere &s = GetCForm()->getSphere(); Fvector P; XFORM().transform_tiny (P,s.P); feel_touch_update (P,s.R); @@ -140,7 +140,7 @@ bool CTeamBaseZone::feel_touch_contact (CObject* O) { CActor* pActor = smart_cast(O); if (!pActor) return (false); - return ((CCF_Shape*)CFORM())->Contact(O); + return ((CCF_Shape*)GetCForm())->Contact(O); } #ifdef DEBUG @@ -152,7 +152,7 @@ void CTeamBaseZone::OnRender() // RCache.OnFrameEnd(); Fvector l_half; l_half.set(.5f, .5f, .5f); Fmatrix l_ball, l_box; - xr_vector &l_shapes = ((CCF_Shape*)CFORM())->Shapes(); + xr_vector &l_shapes = ((CCF_Shape*)GetCForm())->Shapes(); xr_vector::iterator l_pShape; for(l_pShape = l_shapes.begin(); l_shapes.end() != l_pShape; ++l_pShape)