diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-07-04 22:56:00 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2024-07-04 22:56:00 +0200 |
commit | ff4fc1ad4e91e3da9cd8c011f30473a19a3d47bd (patch) | |
tree | a37fc61a59a39520a88d024846a900c63988a0b0 /src/common/Collision/Models/ModelInstance.h | |
parent | fd329ee8483da81585db484c005a6fe22448bc63 (diff) |
Core/Vmaps: Replace manual reference counting with shared_ptr and slightly reduce memory use by deduplicating model name strings
Diffstat (limited to 'src/common/Collision/Models/ModelInstance.h')
-rw-r--r-- | src/common/Collision/Models/ModelInstance.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/Collision/Models/ModelInstance.h b/src/common/Collision/Models/ModelInstance.h index 7361fbb9335..78b07f11f4b 100644 --- a/src/common/Collision/Models/ModelInstance.h +++ b/src/common/Collision/Models/ModelInstance.h @@ -18,12 +18,12 @@ #ifndef _MODELINSTANCE_H_ #define _MODELINSTANCE_H_ -#include <G3D/Matrix3.h> -#include <G3D/Vector3.h> +#include "Define.h" +#include <memory> #include <G3D/AABox.h> +#include <G3D/Matrix3.h> #include <G3D/Ray.h> - -#include "Define.h" +#include <G3D/Vector3.h> namespace VMAP { @@ -70,17 +70,17 @@ namespace VMAP { public: ModelInstance() : iInvScale(0.0f), iModel(nullptr) { } - ModelInstance(ModelSpawn const& spawn, WorldModel* model); + ModelInstance(ModelSpawn const& spawn, std::shared_ptr<WorldModel> model); void setUnloaded() { iModel = nullptr; } bool intersectRay(G3D::Ray const& pRay, float& pMaxDist, bool pStopAtFirstHit, ModelIgnoreFlags ignoreFlags) const; bool GetLocationInfo(G3D::Vector3 const& p, LocationInfo& info) const; bool GetLiquidLevel(G3D::Vector3 const& p, LocationInfo& info, float& liqHeight) const; G3D::Matrix3 const& GetInvRot() const { return iInvRot; } - WorldModel const* getWorldModel() const { return iModel; } + WorldModel const* getWorldModel() const { return iModel.get(); } protected: G3D::Matrix3 iInvRot; float iInvScale; - WorldModel* iModel; + std::shared_ptr<WorldModel> iModel; }; } // namespace VMAP |