Index: source/graphics/Decal.h =================================================================== --- source/graphics/Decal.h +++ source/graphics/Decal.h @@ -19,7 +19,7 @@ #define INCLUDED_DECAL #include "graphics/Material.h" -#include "graphics/ModelAbstract.h" +#include "graphics/SceneObject.h" #include "graphics/Texture.h" class CTerrain; @@ -47,7 +47,7 @@ bool m_Floating; }; -class CModelDecal : public CModelAbstract +class CModelDecal : public CSceneObject { public: CModelDecal(CTerrain* terrain, const SDecal& decal) @@ -62,7 +62,7 @@ return this; } - virtual CModelAbstract* Clone() const; + virtual CSceneObject* Clone() const; virtual void SetDirtyRec(int dirtyflags) { Index: source/graphics/Decal.cpp =================================================================== --- source/graphics/Decal.cpp +++ source/graphics/Decal.cpp @@ -22,7 +22,7 @@ #include "graphics/Terrain.h" #include "maths/MathUtil.h" -CModelAbstract* CModelDecal::Clone() const +CSceneObject* CModelDecal::Clone() const { CModelDecal* clone = new CModelDecal(m_Terrain, m_Decal); return clone; Index: source/graphics/Model.h =================================================================== --- source/graphics/Model.h +++ source/graphics/Model.h @@ -27,7 +27,7 @@ #include "graphics/Texture.h" #include "graphics/Material.h" #include "graphics/MeshManager.h" -#include "graphics/ModelAbstract.h" +#include "graphics/SceneObject.h" struct SPropPoint; class CObjectEntry; @@ -35,6 +35,7 @@ class CSkeletonAnimDef; class CSkeletonAnimManager; class CSimulation2; +class CUnit; #define MODELFLAG_CASTSHADOWS (1<<0) #define MODELFLAG_NOLOOPANIMATION (1<<1) @@ -45,7 +46,7 @@ /////////////////////////////////////////////////////////////////////////////// // CModel: basically, a mesh object - holds the texturing and skinning // information for a model in game -class CModel : public CModelAbstract +class CModel : public CSceneObject { NONCOPYABLE(CModel); @@ -69,7 +70,7 @@ * space transform, taking into account all parent model positioning (see @ref CModel::ValidatePosition for positioning logic). * @see CModel::ValidatePosition */ - CModelAbstract* m_Model; + CSceneObject* m_Model; CObjectEntry* m_ObjectEntry; bool m_Hidden; ///< Should this prop be temporarily removed from rendering? @@ -97,12 +98,11 @@ // get the model's geometry data const CModelDefPtr& GetModelDef() { return m_pModelDef; } + // Update our owner, also update props. + virtual void SetOwner(CUnit* owner); + // set the model's material void SetMaterial(const CMaterial &material); - // set the model's player ID, recursively through props - void SetPlayerID(player_id_t id); - // set the models mod color - virtual void SetShadingColor(const CColor& color); // get the model's material CMaterial& GetMaterial() { return m_Material; } @@ -214,13 +214,13 @@ /** * Add a prop to the model on the given point. */ - void AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry, float minHeight = 0.f, float maxHeight = 0.f, bool selectable = true); + void AddProp(const SPropPoint* point, CSceneObject* model, CObjectEntry* objectentry, float minHeight = 0.f, float maxHeight = 0.f, bool selectable = true); /** * Add a prop to the model on the given point, and treat it as the ammo prop. * The prop will be hidden by default. */ - void AddAmmoProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry); + void AddAmmoProp(const SPropPoint* point, CSceneObject* model, CObjectEntry* objectentry); /** * Show the ammo prop (if any), and hide any other props on that prop point. @@ -235,14 +235,14 @@ /** * Find the first prop used for ammo, by this model or its own props. */ - CModelAbstract* FindFirstAmmoProp(); + CSceneObject* FindFirstAmmoProp(); // return prop list std::vector& GetProps() { return m_Props; } const std::vector& GetProps() const { return m_Props; } // return a clone of this model - virtual CModelAbstract* Clone() const; + virtual CSceneObject* Clone() const; /** * Ensure that both the transformation and the bone Index: source/graphics/Model.cpp =================================================================== --- source/graphics/Model.cpp +++ source/graphics/Model.cpp @@ -100,6 +100,12 @@ return true; } +void CModel::SetOwner(CUnit* owner) +{ + CSceneObject::SetOwner(owner); + for (Prop& prop : m_Props) + prop.m_Model->SetOwner(owner); +} ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // CalcBound: calculate the world space bounds of this model @@ -161,7 +167,7 @@ // at the origin. The box is later re-transformed onto the object, without // having to recalculate the size of the box. CMatrix3D transform, oldtransform = GetTransform(); - CModelAbstract* oldparent = m_Parent; + CSceneObject* oldparent = m_Parent; m_Parent = 0; transform.SetIdentity(); @@ -509,13 +515,13 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // AddProp: add a prop to the model on the given point -void CModel::AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry, float minHeight, float maxHeight, bool selectable) +void CModel::AddProp(const SPropPoint* point, CSceneObject* model, CObjectEntry* objectentry, float minHeight, float maxHeight, bool selectable) { // position model according to prop point position // this next call will invalidate the bounds of "model", which will in turn also invalidate the selection box model->SetTransform(point->m_Transform); - model->m_Parent = this; + model->SetParent(this); Prop prop; prop.m_Point = point; @@ -527,7 +533,7 @@ m_Props.push_back(prop); } -void CModel::AddAmmoProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry) +void CModel::AddAmmoProp(const SPropPoint* point, CSceneObject* model, CObjectEntry* objectentry) { AddProp(point, model, objectentry); m_AmmoPropPoint = point; @@ -569,7 +575,7 @@ m_SelectionBoxValid = false; } -CModelAbstract* CModel::FindFirstAmmoProp() +CSceneObject* CModel::FindFirstAmmoProp() { if (m_AmmoPropPoint) return m_Props[m_AmmoLoadedProp].m_Model; @@ -579,7 +585,7 @@ CModel* propModel = m_Props[i].m_Model->ToCModel(); if (propModel) { - CModelAbstract* model = propModel->FindFirstAmmoProp(); + CSceneObject* model = propModel->FindFirstAmmoProp(); if (model) return model; } @@ -590,7 +596,7 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // Clone: return a clone of this model -CModelAbstract* CModel::Clone() const +CSceneObject* CModel::Clone() const { CModel* clone = new CModel(m_SkeletonAnimManager, m_Simulation); clone->m_ObjectBounds = m_ObjectBounds; @@ -658,19 +664,3 @@ { m_Material = material; } - -void CModel::SetPlayerID(player_id_t id) -{ - CModelAbstract::SetPlayerID(id); - - for (std::vector::iterator it = m_Props.begin(); it != m_Props.end(); ++it) - it->m_Model->SetPlayerID(id); -} - -void CModel::SetShadingColor(const CColor& color) -{ - CModelAbstract::SetShadingColor(color); - - for (std::vector::iterator it = m_Props.begin(); it != m_Props.end(); ++it) - it->m_Model->SetShadingColor(color); -} Index: source/graphics/ObjectEntry.h =================================================================== --- source/graphics/ObjectEntry.h +++ source/graphics/ObjectEntry.h @@ -18,7 +18,7 @@ #ifndef INCLUDED_OBJECTENTRY #define INCLUDED_OBJECTENTRY -class CModelAbstract; +class CSceneObject; class CSkeletonAnim; class CObjectBase; class CObjectManager; @@ -78,7 +78,7 @@ std::vector GetAnimations(const CStr& animationName, const CStr& ID = "") const; // corresponding model - CModelAbstract* m_Model; + CSceneObject* m_Model; // Whether this object is outdated, due to hotloading of its base object. // (If true then CObjectManager won't reuse this object from its cache.) Index: source/graphics/ObjectEntry.cpp =================================================================== --- source/graphics/ObjectEntry.cpp +++ source/graphics/ObjectEntry.cpp @@ -234,7 +234,7 @@ const SPropPoint* proppoint = modeldef->FindPropPoint(ppn.c_str()); if (proppoint) { - CModelAbstract* propmodel = oe->m_Model->Clone(); + CSceneObject* propmodel = oe->m_Model->Clone(); if (isAmmo) model->AddAmmoProp(proppoint, propmodel, oe); else Index: source/graphics/ParticleEmitter.h =================================================================== --- source/graphics/ParticleEmitter.h +++ source/graphics/ParticleEmitter.h @@ -18,7 +18,7 @@ #ifndef INCLUDED_PARTICLEEMITTER #define INCLUDED_PARTICLEEMITTER -#include "graphics/ModelAbstract.h" +#include "graphics/SceneObject.h" #include "graphics/ParticleEmitterType.h" #include "graphics/Texture.h" #include "maths/Quaternion.h" @@ -173,7 +173,7 @@ /** * Particle emitter model, for attaching emitters as props on other models. */ -class CModelParticleEmitter : public CModelAbstract +class CModelParticleEmitter : public CSceneObject { public: CModelParticleEmitter(const CParticleEmitterTypePtr& type); @@ -185,7 +185,7 @@ return this; } - virtual CModelAbstract* Clone() const; + virtual CSceneObject* Clone() const; virtual void SetDirtyRec(int dirtyflags) { Index: source/graphics/ParticleEmitter.cpp =================================================================== --- source/graphics/ParticleEmitter.cpp +++ source/graphics/ParticleEmitter.cpp @@ -259,7 +259,7 @@ m_Emitter->SetEntityVariable(name, value); } -CModelAbstract* CModelParticleEmitter::Clone() const +CSceneObject* CModelParticleEmitter::Clone() const { return new CModelParticleEmitter(m_Type); } Index: source/graphics/SceneObject.h =================================================================== --- source/graphics/SceneObject.h +++ source/graphics/SceneObject.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -26,16 +26,19 @@ class CModel; class CModelDecal; class CModelParticleEmitter; +class CUnit; /** - * Abstract base class for graphical objects that are used by units, - * or as props attached to other CModelAbstract objects. + * Abstract base class for graphical objects in the scene. * This includes meshes, terrain decals, and sprites. - * These objects exist in a tree hierarchy. + * These objects exist in a tree hierarchy, + * and are ultimately owned by a CUnit. + * Note that CSceneObject currently doesn't keep a reference to its children, + * since only CModel can actually have children. */ -class CModelAbstract : public CRenderableObject +class CSceneObject : public CRenderableObject { - NONCOPYABLE(CModelAbstract); + NONCOPYABLE(CSceneObject); public: @@ -60,17 +63,23 @@ public: - CModelAbstract() - : m_Parent(NULL), m_PositionValid(false), m_ShadingColor(1, 1, 1, 1), m_PlayerID(INVALID_PLAYER), - m_SelectionBoxValid(false), m_CustomSelectionShape(NULL) + CSceneObject() + : m_Owner(nullptr), m_Parent(nullptr), m_PositionValid(false), + m_SelectionBoxValid(false), m_CustomSelectionShape(nullptr) { } - ~CModelAbstract() + ~CSceneObject() { delete m_CustomSelectionShape; // allocated and set externally by CCmpVisualActor, but our responsibility to clean up } - virtual CModelAbstract* Clone() const = 0; + void SetParent(CSceneObject* object); + CSceneObject* GetParent() const; + + virtual void SetOwner(CUnit* owner); + CUnit* GetOwner() const; + + virtual CSceneObject* Clone() const = 0; /// Dynamic cast virtual CModel* ToCModel() { return NULL; } @@ -149,30 +158,21 @@ */ virtual void InvalidatePosition() = 0; - virtual void SetPlayerID(player_id_t id) { m_PlayerID = id; } - - // get the model's player ID; initial default is INVALID_PLAYER - virtual player_id_t GetPlayerID() const { return m_PlayerID; } - - virtual void SetShadingColor(const CColor& color) { m_ShadingColor = color; } - virtual CColor GetShadingColor() const { return m_ShadingColor; } - protected: void CalcSelectionBox(); public: - /// If non-null, points to the model that we are attached to. - CModelAbstract* m_Parent; - /// True if both transform and and bone matrices are valid. bool m_PositionValid; - player_id_t m_PlayerID; - - /// Modulating color - CColor m_ShadingColor; - protected: + /// If non-null, points to the model that we are attached to. + CSceneObject* m_Parent; + + /** + * Parent CUnit. This is the top-level object to which props and props of props also point to. + */ + CUnit* m_Owner; /// Selection box for this model. CBoundingBoxOriented m_SelectionBox; Index: source/graphics/SceneObject.cpp =================================================================== --- source/graphics/SceneObject.cpp +++ source/graphics/SceneObject.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -17,11 +17,31 @@ #include "precompiled.h" -#include "ModelAbstract.h" +#include "SceneObject.h" #include "ps/CLogger.h" -const CBoundingBoxOriented& CModelAbstract::GetSelectionBox() +void CSceneObject::SetParent(CSceneObject* object) +{ + m_Parent = object; + SetOwner(object->GetOwner()); +} +CSceneObject* CSceneObject::GetParent() const +{ + return m_Parent; +} + +void CSceneObject::SetOwner(CUnit* owner) +{ + m_Owner = owner; +} + +CUnit* CSceneObject::GetOwner() const +{ + return m_Owner; +} + +const CBoundingBoxOriented& CSceneObject::GetSelectionBox() { if (!m_SelectionBoxValid) { @@ -31,7 +51,7 @@ return m_SelectionBox; } -void CModelAbstract::CalcSelectionBox() +void CSceneObject::CalcSelectionBox() { if (m_CustomSelectionShape) { Index: source/graphics/Unit.h =================================================================== --- source/graphics/Unit.h +++ source/graphics/Unit.h @@ -21,16 +21,17 @@ #include #include +#include "graphics/Color.h" #include "ps/CStr.h" +#include "simulation2/helpers/Player.h" #include "simulation2/system/Entity.h" // entity_id_t -class CModelAbstract; +class CSceneObject; class CObjectEntry; class CObjectManager; class CSkeletonAnim; class CUnitAnimation; - ///////////////////////////////////////////////////////////////////////////////////////////// // CUnit: simple "actor" definition - defines a sole object within the world class CUnit @@ -51,13 +52,14 @@ // destructor ~CUnit(); - // get unit's template object - const CObjectEntry& GetObject() const { return *m_Object; } // get unit's model data - CModelAbstract& GetModel() const { return *m_Model; } + CSceneObject& GetModel() const { return *m_Model; } CUnitAnimation* GetAnimation() { return m_Animation; } + std::wstring GetProjectileModelName() const; + bool GetFloatingActor() const; + /** * Update the model's animation. * @param frameTime time in seconds @@ -79,11 +81,17 @@ void SetActorSelections(const std::set& selections); + void SetPlayerID(player_id_t id) { m_PlayerID = id; } + player_id_t GetPlayerID() const { return m_PlayerID; } + + void SetShadingColor(const CColor& color) { m_ShadingColor = color; } + CColor GetShadingColor() const { return m_ShadingColor; } + private: // object from which unit was created; never NULL CObjectEntry* m_Object; // object model representation; never NULL - CModelAbstract* m_Model; + CSceneObject* m_Model; CUnitAnimation* m_Animation; @@ -99,6 +107,12 @@ // entity-level selections for this unit std::map m_EntitySelections; + // Player ID for player-color rendering. + player_id_t m_PlayerID = INVALID_PLAYER; + + /// Modulating color + CColor m_ShadingColor = CColor(1.f, 1.f, 1.f, 1.f); + // object manager which looks after this unit's objectentry CObjectManager& m_ObjectManager; Index: source/graphics/Unit.cpp =================================================================== --- source/graphics/Unit.cpp +++ source/graphics/Unit.cpp @@ -32,6 +32,7 @@ m_ID(INVALID_ENTITY), m_ActorSelections(actorSelections), m_ObjectManager(objectManager), m_Seed(seed) { + m_Model->SetOwner(this); if (m_Model->ToCModel()) m_Animation = new CUnitAnimation(m_ID, m_Model->ToCModel(), m_Object); else @@ -64,6 +65,10 @@ return new CUnit(obj, objectManager, actorSelections, seed); } +std::wstring CUnit::GetProjectileModelName() const { return m_Object->m_ProjectileModelName; } + +bool CUnit::GetFloatingActor() const { return m_Object->m_Base->m_Properties.m_FloatOnWater; } + void CUnit::UpdateModel(float frameTime) { if (m_Animation) @@ -126,11 +131,11 @@ if (newObject && newObject != m_Object) { // Clone the new object's base (non-instance) model - CModelAbstract* newModel = newObject->m_Model->Clone(); + CSceneObject* newModel = newObject->m_Model->Clone(); + + newModel->SetOwner(this); // Copy the old instance-specific settings from the old model to the new instance - newModel->SetTransform(m_Model->GetTransform()); - newModel->SetPlayerID(m_Model->GetPlayerID()); if (newModel->ToCModel() && m_Model->ToCModel()) { newModel->ToCModel()->CopyAnimationFrom(m_Model->ToCModel()); Index: source/renderer/DecalRData.cpp =================================================================== --- source/renderer/DecalRData.cpp +++ source/renderer/DecalRData.cpp @@ -24,6 +24,7 @@ #include "graphics/ShaderManager.h" #include "graphics/Terrain.h" #include "graphics/TextureManager.h" +#include "graphics/Unit.h" #include "ps/CLogger.h" #include "ps/Game.h" #include "ps/Profile.h" @@ -136,7 +137,7 @@ u8* indexBase = decal->m_IndexArray.Bind(); - shader->Uniform(str_shadingColor, decal->m_Decal->GetShadingColor()); + shader->Uniform(str_shadingColor, decal->m_Decal->GetOwner()->GetShadingColor()); shader->VertexPointer(3, GL_FLOAT, stride, base + decal->m_Position.offset); shader->NormalPointer(GL_FLOAT, stride, base + decal->m_Normal.offset); Index: source/renderer/ModelRenderer.cpp =================================================================== --- source/renderer/ModelRenderer.cpp +++ source/renderer/ModelRenderer.cpp @@ -24,6 +24,7 @@ #include "graphics/ModelDef.h" #include "graphics/ShaderManager.h" #include "graphics/TextureManager.h" +#include "graphics/Unit.h" #include "lib/allocators/DynamicArena.h" #include "lib/allocators/STLAllocators.h" #include "lib/hash.h" @@ -114,7 +115,7 @@ CModelDefPtr mdef = model->GetModelDef(); size_t numVertices = mdef->GetNumVertices(); const CLightEnv& lightEnv = g_Renderer.GetLightEnv(); - CColor shadingColor = model->GetShadingColor(); + CColor shadingColor = model->GetOwner()->GetShadingColor(); for (size_t j = 0; j < numVertices; ++j) { Index: source/renderer/RenderModifiers.cpp =================================================================== --- source/renderer/RenderModifiers.cpp +++ source/renderer/RenderModifiers.cpp @@ -33,6 +33,7 @@ #include "graphics/LOSTexture.h" #include "graphics/Model.h" #include "graphics/TextureManager.h" +#include "graphics/Unit.h" #include "renderer/RenderModifiers.h" #include "renderer/Renderer.h" @@ -108,8 +109,8 @@ shader->Uniform(m_BindingInstancingTransform, model->GetTransform()); if (m_BindingShadingColor.Active()) - shader->Uniform(m_BindingShadingColor, model->GetShadingColor()); + shader->Uniform(m_BindingShadingColor, model->GetOwner()->GetShadingColor()); if (m_BindingPlayerColor.Active()) - shader->Uniform(m_BindingPlayerColor, g_Game->GetPlayerColor(model->GetPlayerID())); + shader->Uniform(m_BindingPlayerColor, g_Game->GetPlayerColor(model->GetOwner()->GetPlayerID())); } Index: source/renderer/Scene.h =================================================================== --- source/renderer/Scene.h +++ source/renderer/Scene.h @@ -30,7 +30,7 @@ class CFrustum; class CModel; -class CModelAbstract; +class CSceneObject; class CModelDecal; class CParticleEmitter; class CPatch; @@ -138,7 +138,7 @@ * @note This function is implemented using SubmitNonRecursive, * so you shouldn't have to reimplement it. */ - virtual void SubmitRecursive(CModelAbstract* model); + virtual void SubmitRecursive(CSceneObject* model); }; Index: source/renderer/Scene.cpp =================================================================== --- source/renderer/Scene.cpp +++ source/renderer/Scene.cpp @@ -34,7 +34,7 @@ /////////////////////////////////////////////////////////// // Default implementation traverses the model recursively and uses // SubmitNonRecursive for the actual work. -void SceneCollector::SubmitRecursive(CModelAbstract* model) +void SceneCollector::SubmitRecursive(CSceneObject* model) { if (model->ToCModel()) { Index: source/simulation2/components/CCmpProjectileManager.cpp =================================================================== --- source/simulation2/components/CCmpProjectileManager.cpp +++ source/simulation2/components/CCmpProjectileManager.cpp @@ -114,7 +114,7 @@ virtual void RemoveProjectile(uint32_t); - void RenderModel(CModelAbstract& model, const CVector3D& position, SceneCollector& collector, const CFrustum& frustum, bool culling, + void RenderModel(CSceneObject& model, const CVector3D& position, SceneCollector& collector, const CFrustum& frustum, bool culling, const CLosQuerier& los, bool losRevealAll) const; private: @@ -358,7 +358,7 @@ } } -void CCmpProjectileManager::RenderModel(CModelAbstract& model, const CVector3D& position, SceneCollector& collector, +void CCmpProjectileManager::RenderModel(CSceneObject& model, const CVector3D& position, SceneCollector& collector, const CFrustum& frustum, bool culling, const CLosQuerier& los, bool losRevealAll) const { // Don't display objects outside the visible area Index: source/simulation2/components/CCmpUnitRenderer.cpp =================================================================== --- source/simulation2/components/CCmpUnitRenderer.cpp +++ source/simulation2/components/CCmpUnitRenderer.cpp @@ -29,7 +29,7 @@ #include "ICmpVisual.h" #include "graphics/Frustum.h" -#include "graphics/ModelAbstract.h" +#include "graphics/SceneObject.h" #include "graphics/ObjectEntry.h" #include "graphics/Overlay.h" #include "graphics/Unit.h" @@ -418,7 +418,7 @@ unit.culled = false; - CModelAbstract& unitModel = unit.actor->GetModel(); + CSceneObject& unitModel = unit.actor->GetModel(); if (unit.lastTransformFrame != m_FrameNumber) { Index: source/simulation2/components/CCmpVisualActor.cpp =================================================================== --- source/simulation2/components/CCmpVisualActor.cpp +++ source/simulation2/components/CCmpVisualActor.cpp @@ -72,7 +72,7 @@ // Not initialized in non-visual mode CUnit* m_Unit; - CModelAbstract::CustomSelectionShape* m_ShapeDescriptor = nullptr; + CSceneObject::CustomSelectionShape* m_ShapeDescriptor = nullptr; fixed m_R, m_G, m_B; // shading color @@ -285,7 +285,7 @@ { CmpPtr cmpOwnership(GetEntityHandle()); if (cmpOwnership) - m_Unit->GetModel().SetPlayerID(cmpOwnership->GetOwner()); + m_Unit->SetPlayerID(cmpOwnership->GetOwner()); } } @@ -301,7 +301,7 @@ break; const CMessageOwnershipChanged& msgData = static_cast (msg); - m_Unit->GetModel().SetPlayerID(msgData.to); + m_Unit->SetPlayerID(msgData.to); break; } @@ -385,18 +385,11 @@ return m_Unit->GetModel().GetTransform().GetTranslation(); } - virtual std::wstring GetActorShortName() const - { - if (!m_Unit) - return L""; - return m_Unit->GetObject().m_Base->m_ShortName; - } - virtual std::wstring GetProjectileActor() const { if (!m_Unit) return L""; - return m_Unit->GetObject().m_ProjectileModelName; + return m_Unit->GetProjectileModelName(); } virtual CFixedVector3D GetProjectileLaunchPoint() const @@ -417,7 +410,7 @@ m_Unit->GetModel().ValidatePosition(); } - CModelAbstract* ammo = m_Unit->GetModel().ToCModel()->FindFirstAmmoProp(); + CSceneObject* ammo = m_Unit->GetModel().ToCModel()->FindFirstAmmoProp(); if (ammo) { CVector3D vector = ammo->GetTransform().GetTranslation(); @@ -502,10 +495,7 @@ UNUSED2(a); // TODO: why is this even an argument? if (m_Unit) - { - CModelAbstract& model = m_Unit->GetModel(); - model.SetShadingColor(CColor(m_R.ToFloat(), m_G.ToFloat(), m_B.ToFloat(), 1.0f)); - } + m_Unit->SetShadingColor(CColor(m_R.ToFloat(), m_G.ToFloat(), m_B.ToFloat(), 1.0f)); } virtual void SetVariable(const std::string& name, float value) @@ -611,7 +601,7 @@ if (!m_Unit) return; - CModelAbstract& model = m_Unit->GetModel(); + CSceneObject& model = m_Unit->GetModel(); if (model.ToCModel()) { u32 modelFlags = 0; @@ -639,7 +629,7 @@ m_Unit->SetID(GetEntityId()); - bool floating = m_Unit->GetObject().m_Base->m_Properties.m_FloatOnWater; + bool floating = m_Unit->GetFloatingActor(); CmpPtr cmpPosition(GetEntityHandle()); if (cmpPosition) cmpPosition->SetActorFloating(floating); @@ -704,8 +694,8 @@ size1 *= 2; } - m_ShapeDescriptor = new CModelAbstract::CustomSelectionShape; - m_ShapeDescriptor->m_Type = CModelAbstract::CustomSelectionShape::BOX; + m_ShapeDescriptor = new CSceneObject::CustomSelectionShape; + m_ShapeDescriptor->m_Type = CSceneObject::CustomSelectionShape::BOX; m_ShapeDescriptor->m_Size0 = size0; m_ShapeDescriptor->m_Size1 = size1; m_ShapeDescriptor->m_Height = fpHeight.ToFloat(); @@ -718,8 +708,8 @@ else if (shapeNode.GetChild("Box").IsOk()) { // TODO: we might need to support the ability to specify a different box center in the future - m_ShapeDescriptor = new CModelAbstract::CustomSelectionShape; - m_ShapeDescriptor->m_Type = CModelAbstract::CustomSelectionShape::BOX; + m_ShapeDescriptor = new CSceneObject::CustomSelectionShape; + m_ShapeDescriptor->m_Type = CSceneObject::CustomSelectionShape::BOX; m_ShapeDescriptor->m_Size0 = shapeNode.GetChild("Box").GetChild("@width").ToFixed().ToFloat(); m_ShapeDescriptor->m_Size1 = shapeNode.GetChild("Box").GetChild("@depth").ToFixed().ToFloat(); m_ShapeDescriptor->m_Height = shapeNode.GetChild("Box").GetChild("@height").ToFixed().ToFloat(); @@ -742,8 +732,8 @@ return; // Save some data from the old unit - CColor shading = m_Unit->GetModel().GetShadingColor(); - player_id_t playerID = m_Unit->GetModel().GetPlayerID(); + CColor shading = m_Unit->GetShadingColor(); + player_id_t playerID = m_Unit->GetPlayerID(); // Replace with the new unit GetSimContext().GetUnitManager().DeleteUnit(m_Unit); @@ -760,9 +750,9 @@ ReloadUnitAnimation(); - m_Unit->GetModel().SetShadingColor(shading); + m_Unit->SetShadingColor(shading); - m_Unit->GetModel().SetPlayerID(playerID); + m_Unit->SetPlayerID(playerID); if (m_ModelTag.valid()) { Index: source/simulation2/components/ICmpVisual.h =================================================================== --- source/simulation2/components/ICmpVisual.h +++ source/simulation2/components/ICmpVisual.h @@ -54,12 +54,6 @@ */ virtual CVector3D GetPosition() const = 0; - /** - * Return the short name of the actor that's being displayed, or the empty string on error. - * (Not safe for use in simulation code.) - */ - virtual std::wstring GetActorShortName() const = 0; - /** * Return the filename of the actor to be used for projectiles from this unit, or the empty string if none. * (Not safe for use in simulation code.) Index: source/tools/atlas/GameInterface/ActorViewer.cpp =================================================================== --- source/tools/atlas/GameInterface/ActorViewer.cpp +++ source/tools/atlas/GameInterface/ActorViewer.cpp @@ -212,7 +212,7 @@ * Recursively fetches the props of the currently displayed entity model and its submodels, and stores them for rendering. */ void UpdatePropList(); - void UpdatePropListRecursive(CModelAbstract* model); + void UpdatePropListRecursive(CSceneObject* model); }; @@ -226,13 +226,13 @@ CUnit* unit = cmpVisual->GetUnit(); if (unit) { - CModelAbstract& modelAbstract = unit->GetModel(); + CSceneObject& modelAbstract = unit->GetModel(); UpdatePropListRecursive(&modelAbstract); } } } -void ActorViewerImpl::UpdatePropListRecursive(CModelAbstract* modelAbstract) +void ActorViewerImpl::UpdatePropListRecursive(CSceneObject* modelAbstract) { ENSURE(modelAbstract);