Added ResourceRef (Automatic resource reference)
Former-commit-id: 97a0b2732f4dc443b8e1676e68b33b1b53ddf4fb
This commit is contained in:
parent
4ee6ca05ed
commit
6c2fb1eb89
|
|
@ -78,11 +78,11 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||||
void UpdateBoundingBox() const;
|
void UpdateBoundingBox() const;
|
||||||
bool VisibilityTest(const NzFrustumf& frustum) override;
|
bool VisibilityTest(const NzFrustumf& frustum) override;
|
||||||
|
|
||||||
std::vector<NzMaterial*> m_materials;
|
std::vector<NzMaterialRef> m_materials;
|
||||||
mutable NzBoundingBoxf m_boundingBox;
|
mutable NzBoundingBoxf m_boundingBox;
|
||||||
NzSkeleton m_skeleton; // Uniquement pour les animations squelettiques
|
NzSkeleton m_skeleton; // Uniquement pour les animations squelettiques
|
||||||
NzAnimation* m_animation;
|
NzAnimationRef m_animation;
|
||||||
NzMesh* m_mesh;
|
NzMeshRef m_mesh;
|
||||||
const NzSequence* m_currentSequence;
|
const NzSequence* m_currentSequence;
|
||||||
bool m_animationEnabled;
|
bool m_animationEnabled;
|
||||||
mutable bool m_boundingBoxUpdated;
|
mutable bool m_boundingBoxUpdated;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class NAZARA_API NzSound : public NzSoundEmitter
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const NzSoundBuffer* m_buffer = nullptr;
|
NzSoundBufferConstRef m_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NAZARA_SOUND_HPP
|
#endif // NAZARA_SOUND_HPP
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <Nazara/Core/NonCopyable.hpp>
|
#include <Nazara/Core/NonCopyable.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Core/ResourceLoader.hpp>
|
#include <Nazara/Core/ResourceLoader.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
|
|
||||||
struct NzSoundBufferParams
|
struct NzSoundBufferParams
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +23,9 @@ struct NzSoundBufferParams
|
||||||
class NzSound;
|
class NzSound;
|
||||||
class NzSoundBuffer;
|
class NzSoundBuffer;
|
||||||
|
|
||||||
|
using NzSoundBufferConstRef = NzResourceRef<const NzSoundBuffer>;
|
||||||
using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>;
|
using NzSoundBufferLoader = NzResourceLoader<NzSoundBuffer, NzSoundBufferParams>;
|
||||||
|
using NzSoundBufferRef = NzResourceRef<NzSoundBuffer>;
|
||||||
|
|
||||||
struct NzSoundBufferImpl;
|
struct NzSoundBufferImpl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ class NAZARA_API NzResource
|
||||||
|
|
||||||
bool IsPersistent() const;
|
bool IsPersistent() const;
|
||||||
|
|
||||||
void RemoveResourceListener(NzResourceListener* listener) const;
|
bool RemoveResourceListener(NzResourceListener* listener) const;
|
||||||
void RemoveResourceReference() const;
|
bool RemoveResourceReference() const;
|
||||||
|
|
||||||
void SetPersistent(bool persistent = true, bool checkReferenceCount = true);
|
void SetPersistent(bool persistent = true, bool checkReferenceCount = true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright (C) 2013 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Core module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_RESOURCEREF_HPP
|
||||||
|
#define NAZARA_RESOURCEREF_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class NzResourceRef
|
||||||
|
{
|
||||||
|
static_assert(std::is_base_of<NzResource, T>::value, "ResourceRef should only be used with resource type");
|
||||||
|
|
||||||
|
public:
|
||||||
|
NzResourceRef() = default;
|
||||||
|
NzResourceRef(T* resource);
|
||||||
|
NzResourceRef(const NzResourceRef& ref);
|
||||||
|
NzResourceRef(NzResourceRef&& ref);
|
||||||
|
~NzResourceRef();
|
||||||
|
|
||||||
|
bool IsValid() const;
|
||||||
|
T* Release();
|
||||||
|
bool Reset(T* resource = nullptr);
|
||||||
|
NzResourceRef& Swap(NzResourceRef& ref);
|
||||||
|
|
||||||
|
operator bool() const;
|
||||||
|
operator T*() const;
|
||||||
|
T* operator->() const;
|
||||||
|
|
||||||
|
NzResourceRef& operator=(const NzResourceRef& ref);
|
||||||
|
NzResourceRef& operator=(NzResourceRef&& ref);
|
||||||
|
|
||||||
|
private:
|
||||||
|
T* m_resource = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include <Nazara/Core/ResourceRef.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_RESOURCEREF_HPP
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
// Copyright (C) 2013 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Core module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
// http://www.easyrgb.com/index.php?X=MATH
|
||||||
|
|
||||||
|
#include <Nazara/Core/Initializer.hpp>
|
||||||
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>::NzResourceRef(T* resource) :
|
||||||
|
m_resource(resource)
|
||||||
|
{
|
||||||
|
if (m_resource)
|
||||||
|
m_resource->AddResourceReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>::NzResourceRef(const NzResourceRef& ref) :
|
||||||
|
m_resource(ref.m_resource)
|
||||||
|
{
|
||||||
|
if (m_resource)
|
||||||
|
m_resource->AddResourceReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>::NzResourceRef(NzResourceRef&& ref) :
|
||||||
|
m_resource(ref.m_resource)
|
||||||
|
{
|
||||||
|
ref.m_resource = nullptr; // On vole la référence
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>::~NzResourceRef()
|
||||||
|
{
|
||||||
|
if (m_resource)
|
||||||
|
m_resource->RemoveResourceReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzResourceRef<T>::IsValid() const
|
||||||
|
{
|
||||||
|
return m_resource != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* NzResourceRef<T>::Release()
|
||||||
|
{
|
||||||
|
T* resource = m_resource;
|
||||||
|
m_resource = nullptr;
|
||||||
|
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzResourceRef<T>::Reset(T* resource)
|
||||||
|
{
|
||||||
|
bool destroyed = false;
|
||||||
|
if (m_resource)
|
||||||
|
{
|
||||||
|
destroyed = m_resource->RemoveResourceReference();
|
||||||
|
m_resource = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_resource = resource;
|
||||||
|
if (m_resource)
|
||||||
|
m_resource->AddResourceReference();
|
||||||
|
|
||||||
|
return destroyed;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>& NzResourceRef<T>::Swap(NzResourceRef& ref)
|
||||||
|
{
|
||||||
|
std::swap(m_resource, ref.m_resource);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>::operator bool() const
|
||||||
|
{
|
||||||
|
return IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>::operator T*() const
|
||||||
|
{
|
||||||
|
return m_resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* NzResourceRef<T>::operator->() const
|
||||||
|
{
|
||||||
|
return m_resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>& NzResourceRef<T>::operator=(const NzResourceRef& ref)
|
||||||
|
{
|
||||||
|
if (m_resource != ref.m_resource)
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
|
||||||
|
if (ref)
|
||||||
|
{
|
||||||
|
m_resource = ref.m_resource;
|
||||||
|
m_resource->AddResourceReference();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>& NzResourceRef<T>::operator=(NzResourceRef&& ref)
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
|
||||||
|
std::swap(m_resource, ref.m_resource);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
@ -9,8 +9,14 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||||
|
|
||||||
|
class NzContext;
|
||||||
|
|
||||||
|
using NzContextConstRef = NzResourceRef<const NzContext>;
|
||||||
|
using NzContextRef = NzResourceRef<NzContext>;
|
||||||
|
|
||||||
class NzContextImpl;
|
class NzContextImpl;
|
||||||
|
|
||||||
class NAZARA_API NzContext : public NzResource
|
class NAZARA_API NzContext : public NzResource
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,11 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Color.hpp>
|
#include <Nazara/Core/Color.hpp>
|
||||||
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Core/ResourceLoader.hpp>
|
#include <Nazara/Core/ResourceLoader.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Renderer/Enums.hpp>
|
#include <Nazara/Renderer/Enums.hpp>
|
||||||
|
#include <Nazara/Renderer/Shader.hpp>
|
||||||
#include <Nazara/Renderer/Texture.hpp>
|
#include <Nazara/Renderer/Texture.hpp>
|
||||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||||
|
|
||||||
|
|
@ -23,9 +26,10 @@ struct NAZARA_API NzMaterialParams
|
||||||
};
|
};
|
||||||
|
|
||||||
class NzMaterial;
|
class NzMaterial;
|
||||||
class NzShader;
|
|
||||||
|
|
||||||
|
using NzMaterialConstRef = NzResourceRef<const NzMaterial>;
|
||||||
using NzMaterialLoader = NzResourceLoader<NzMaterial, NzMaterialParams>;
|
using NzMaterialLoader = NzResourceLoader<NzMaterial, NzMaterialParams>;
|
||||||
|
using NzMaterialRef = NzResourceRef<NzMaterial>;
|
||||||
|
|
||||||
class NAZARA_API NzMaterial : public NzResource
|
class NAZARA_API NzMaterial : public NzResource
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +39,7 @@ class NAZARA_API NzMaterial : public NzResource
|
||||||
NzMaterial();
|
NzMaterial();
|
||||||
NzMaterial(const NzMaterial& material);
|
NzMaterial(const NzMaterial& material);
|
||||||
NzMaterial(NzMaterial&& material);
|
NzMaterial(NzMaterial&& material);
|
||||||
~NzMaterial();
|
~NzMaterial() = default;
|
||||||
|
|
||||||
void Apply(const NzShader* shader) const;
|
void Apply(const NzShader* shader) const;
|
||||||
|
|
||||||
|
|
@ -102,6 +106,8 @@ class NAZARA_API NzMaterial : public NzResource
|
||||||
static NzMaterial* GetDefault();
|
static NzMaterial* GetDefault();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Copy(const NzMaterial& material);
|
||||||
|
|
||||||
nzBlendFunc m_dstBlend;
|
nzBlendFunc m_dstBlend;
|
||||||
nzBlendFunc m_srcBlend;
|
nzBlendFunc m_srcBlend;
|
||||||
nzFaceCulling m_faceCulling;
|
nzFaceCulling m_faceCulling;
|
||||||
|
|
@ -113,11 +119,11 @@ class NAZARA_API NzMaterial : public NzResource
|
||||||
NzColor m_specularColor;
|
NzColor m_specularColor;
|
||||||
NzTextureSampler m_diffuseSampler;
|
NzTextureSampler m_diffuseSampler;
|
||||||
NzTextureSampler m_specularSampler;
|
NzTextureSampler m_specularSampler;
|
||||||
mutable const NzShader* m_customShader;
|
mutable NzShaderConstRef m_customShader;
|
||||||
NzTexture* m_diffuseMap;
|
NzTextureRef m_diffuseMap;
|
||||||
NzTexture* m_heightMap;
|
NzTextureRef m_heightMap;
|
||||||
NzTexture* m_normalMap;
|
NzTextureRef m_normalMap;
|
||||||
NzTexture* m_specularMap;
|
NzTextureRef m_specularMap;
|
||||||
bool m_alphaBlendingEnabled;
|
bool m_alphaBlendingEnabled;
|
||||||
bool m_faceCullingEnabled;
|
bool m_faceCullingEnabled;
|
||||||
bool m_lightingEnabled;
|
bool m_lightingEnabled;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include <Nazara/Core/Color.hpp>
|
#include <Nazara/Core/Color.hpp>
|
||||||
#include <Nazara/Core/NonCopyable.hpp>
|
#include <Nazara/Core/NonCopyable.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Math/Matrix4.hpp>
|
#include <Nazara/Math/Matrix4.hpp>
|
||||||
#include <Nazara/Math/Vector2.hpp>
|
#include <Nazara/Math/Vector2.hpp>
|
||||||
|
|
@ -18,9 +19,14 @@
|
||||||
#include <Nazara/Math/Vector4.hpp>
|
#include <Nazara/Math/Vector4.hpp>
|
||||||
#include <Nazara/Renderer/Enums.hpp>
|
#include <Nazara/Renderer/Enums.hpp>
|
||||||
|
|
||||||
class NzShaderImpl;
|
class NzShader;
|
||||||
class NzTexture;
|
class NzTexture;
|
||||||
|
|
||||||
|
using NzShaderConstRef = NzResourceRef<const NzShader>;
|
||||||
|
using NzShaderRef = NzResourceRef<NzShader>;
|
||||||
|
|
||||||
|
class NzShaderImpl;
|
||||||
|
|
||||||
class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
||||||
{
|
{
|
||||||
friend class NzRenderer;
|
friend class NzRenderer;
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,18 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/NonCopyable.hpp>
|
#include <Nazara/Core/NonCopyable.hpp>
|
||||||
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Renderer/Enums.hpp>
|
#include <Nazara/Renderer/Enums.hpp>
|
||||||
#include <Nazara/Utility/Image.hpp>
|
#include <Nazara/Utility/Image.hpp>
|
||||||
#include <Nazara/Utility/PixelFormat.hpp>
|
#include <Nazara/Utility/PixelFormat.hpp>
|
||||||
|
|
||||||
class NzRenderTexture;
|
class NzRenderTexture;
|
||||||
|
class NzTexture;
|
||||||
|
|
||||||
|
using NzTextureConstRef = NzResourceRef<const NzTexture>;
|
||||||
|
using NzTextureRef = NzResourceRef<NzTexture>;
|
||||||
|
|
||||||
struct NzTextureImpl;
|
struct NzTextureImpl;
|
||||||
|
|
||||||
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Core/ResourceLoader.hpp>
|
#include <Nazara/Core/ResourceLoader.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
#include <Nazara/Utility/Sequence.hpp>
|
#include <Nazara/Utility/Sequence.hpp>
|
||||||
|
|
@ -27,7 +28,9 @@ struct NAZARA_API NzAnimationParams
|
||||||
class NzAnimation;
|
class NzAnimation;
|
||||||
class NzSkeleton;
|
class NzSkeleton;
|
||||||
|
|
||||||
|
using NzAnimationConstRef = NzResourceRef<const NzAnimation>;
|
||||||
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
|
using NzAnimationLoader = NzResourceLoader<NzAnimation, NzAnimationParams>;
|
||||||
|
using NzAnimationRef = NzResourceRef<NzAnimation>;
|
||||||
|
|
||||||
struct NzAnimationImpl;
|
struct NzAnimationImpl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,14 @@
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/NonCopyable.hpp>
|
#include <Nazara/Core/NonCopyable.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
|
||||||
|
class NzBuffer;
|
||||||
|
|
||||||
|
using NzBufferConstRef = NzResourceRef<const NzBuffer>;
|
||||||
|
using NzBufferRef = NzResourceRef<NzBuffer>;
|
||||||
|
|
||||||
class NzBufferImpl;
|
class NzBufferImpl;
|
||||||
|
|
||||||
class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <Nazara/Core/InputStream.hpp>
|
#include <Nazara/Core/InputStream.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Core/ResourceLoader.hpp>
|
#include <Nazara/Core/ResourceLoader.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Math/Cube.hpp>
|
#include <Nazara/Math/Cube.hpp>
|
||||||
#include <Nazara/Math/Rect.hpp>
|
#include <Nazara/Math/Rect.hpp>
|
||||||
#include <Nazara/Math/Vector3.hpp>
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
|
|
@ -39,7 +40,9 @@ struct NAZARA_API NzImageParams
|
||||||
|
|
||||||
class NzImage;
|
class NzImage;
|
||||||
|
|
||||||
|
using NzImageConstRef = NzResourceRef<const NzImage>;
|
||||||
using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>;
|
using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>;
|
||||||
|
using NzImageRef = NzResourceRef<NzImage>;
|
||||||
|
|
||||||
class NAZARA_API NzImage : public NzResource
|
class NAZARA_API NzImage : public NzResource
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,14 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Utility/Buffer.hpp>
|
#include <Nazara/Utility/Buffer.hpp>
|
||||||
|
|
||||||
|
class NzIndexBuffer;
|
||||||
|
|
||||||
|
using NzIndexBufferConstRef = NzResourceRef<const NzIndexBuffer>;
|
||||||
|
using NzIndexBufferRef = NzResourceRef<NzIndexBuffer>;
|
||||||
|
|
||||||
class NAZARA_API NzIndexBuffer : public NzResource
|
class NAZARA_API NzIndexBuffer : public NzResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,7 +46,7 @@ class NAZARA_API NzIndexBuffer : public NzResource
|
||||||
void Unmap() const;
|
void Unmap() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NzBuffer* m_buffer;
|
NzBufferRef m_buffer;
|
||||||
bool m_ownsBuffer;
|
bool m_ownsBuffer;
|
||||||
unsigned int m_indexCount;
|
unsigned int m_indexCount;
|
||||||
unsigned int m_startIndex;
|
unsigned int m_startIndex;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Core/ResourceListener.hpp>
|
#include <Nazara/Core/ResourceListener.hpp>
|
||||||
#include <Nazara/Core/ResourceLoader.hpp>
|
#include <Nazara/Core/ResourceLoader.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Math/Cube.hpp>
|
#include <Nazara/Math/Cube.hpp>
|
||||||
#include <Nazara/Utility/Skeleton.hpp>
|
#include <Nazara/Utility/Skeleton.hpp>
|
||||||
|
|
@ -36,7 +37,9 @@ class NzMesh;
|
||||||
|
|
||||||
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
|
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
|
||||||
|
|
||||||
|
using NzMeshConstRef = NzResourceRef<const NzMesh>;
|
||||||
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
|
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
|
||||||
|
using NzMeshRef = NzResourceRef<NzMesh>;
|
||||||
|
|
||||||
struct NzMeshImpl;
|
struct NzMeshImpl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@ struct NzWeight
|
||||||
unsigned int jointIndex;
|
unsigned int jointIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NzSkeletalMesh;
|
||||||
|
|
||||||
|
using NzSkeletalMeshConstRef = NzResourceRef<const NzSkeletalMesh>;
|
||||||
|
using NzSkeletalMeshRef = NzResourceRef<NzSkeletalMesh>;
|
||||||
|
|
||||||
struct NzSkeletalMeshImpl;
|
struct NzSkeletalMeshImpl;
|
||||||
|
|
||||||
class NAZARA_API NzSkeletalMesh final : public NzSubMesh
|
class NAZARA_API NzSkeletalMesh final : public NzSubMesh
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@
|
||||||
#include <Nazara/Core/ResourceListener.hpp>
|
#include <Nazara/Core/ResourceListener.hpp>
|
||||||
#include <Nazara/Utility/SubMesh.hpp>
|
#include <Nazara/Utility/SubMesh.hpp>
|
||||||
|
|
||||||
|
class NzStaticMesh;
|
||||||
|
|
||||||
|
using NzStaticMeshConstRef = NzResourceRef<const NzStaticMesh>;
|
||||||
|
using NzStaticMeshRef = NzResourceRef<NzStaticMesh>;
|
||||||
|
|
||||||
class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Math/Cube.hpp>
|
#include <Nazara/Math/Cube.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||||
|
|
@ -16,6 +17,10 @@
|
||||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||||
|
|
||||||
class NzMesh;
|
class NzMesh;
|
||||||
|
class NzSubMesh;
|
||||||
|
|
||||||
|
using NzSubMeshConstRef = NzResourceRef<const NzSubMesh>;
|
||||||
|
using NzSubMeshRef = NzResourceRef<NzSubMesh>;
|
||||||
|
|
||||||
class NAZARA_API NzSubMesh : public NzResource
|
class NAZARA_API NzSubMesh : public NzResource
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,15 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Utility/Buffer.hpp>
|
#include <Nazara/Utility/Buffer.hpp>
|
||||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||||
|
|
||||||
|
class NzVertexBuffer;
|
||||||
|
|
||||||
|
using NzVertexBufferConstRef = NzResourceRef<NzVertexBuffer>;
|
||||||
|
using NzVertexBufferRef = NzResourceRef<NzVertexBuffer>;
|
||||||
|
|
||||||
class NAZARA_API NzVertexBuffer : public NzResource
|
class NAZARA_API NzVertexBuffer : public NzResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,8 +46,8 @@ class NAZARA_API NzVertexBuffer : public NzResource
|
||||||
void Unmap() const;
|
void Unmap() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NzBuffer* m_buffer;
|
NzBufferRef m_buffer;
|
||||||
const NzVertexDeclaration* m_vertexDeclaration;
|
NzVertexDeclarationConstRef m_vertexDeclaration;
|
||||||
bool m_ownsBuffer;
|
bool m_ownsBuffer;
|
||||||
unsigned int m_startVertex;
|
unsigned int m_startVertex;
|
||||||
unsigned int m_vertexCount;
|
unsigned int m_vertexCount;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
|
#include <Nazara/Core/ResourceRef.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
|
||||||
struct NzVertexElement
|
struct NzVertexElement
|
||||||
|
|
@ -20,6 +21,11 @@ struct NzVertexElement
|
||||||
nzElementUsage usage;
|
nzElementUsage usage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NzVertexDeclaration;
|
||||||
|
|
||||||
|
using NzVertexDeclarationConstRef = NzResourceRef<const NzVertexDeclaration>;
|
||||||
|
using NzVertexDeclarationRef = NzResourceRef<NzVertexDeclaration>;
|
||||||
|
|
||||||
struct NzVertexDeclarationImpl;
|
struct NzVertexDeclarationImpl;
|
||||||
|
|
||||||
class NAZARA_API NzVertexDeclaration : public NzResource
|
class NAZARA_API NzVertexDeclaration : public NzResource
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@
|
||||||
#include <Nazara/3D/Debug.hpp>
|
#include <Nazara/3D/Debug.hpp>
|
||||||
|
|
||||||
NzModel::NzModel() :
|
NzModel::NzModel() :
|
||||||
m_animation(nullptr),
|
|
||||||
m_mesh(nullptr),
|
|
||||||
m_currentSequence(nullptr),
|
m_currentSequence(nullptr),
|
||||||
m_animationEnabled(true),
|
m_animationEnabled(true),
|
||||||
m_boundingBoxUpdated(false),
|
m_boundingBoxUpdated(false),
|
||||||
|
|
@ -27,8 +25,6 @@ NzModel::NzModel(const NzModel& model) :
|
||||||
NzSceneNode(model),
|
NzSceneNode(model),
|
||||||
m_materials(model.m_materials),
|
m_materials(model.m_materials),
|
||||||
m_boundingBox(model.m_boundingBox),
|
m_boundingBox(model.m_boundingBox),
|
||||||
m_animation(model.m_animation),
|
|
||||||
m_mesh(model.m_mesh),
|
|
||||||
m_currentSequence(model.m_currentSequence),
|
m_currentSequence(model.m_currentSequence),
|
||||||
m_animationEnabled(model.m_animationEnabled),
|
m_animationEnabled(model.m_animationEnabled),
|
||||||
m_boundingBoxUpdated(model.m_boundingBoxUpdated),
|
m_boundingBoxUpdated(model.m_boundingBoxUpdated),
|
||||||
|
|
@ -40,19 +36,15 @@ m_nextFrame(model.m_nextFrame),
|
||||||
m_skin(model.m_skin),
|
m_skin(model.m_skin),
|
||||||
m_skinCount(model.m_skinCount)
|
m_skinCount(model.m_skinCount)
|
||||||
{
|
{
|
||||||
if (m_mesh)
|
if (model.m_mesh)
|
||||||
{
|
{
|
||||||
if (m_animation)
|
// Nous n'avons une animation et des matériaux que si nous avons un mesh
|
||||||
m_animation->AddResourceReference();
|
m_animation = model.m_animation;
|
||||||
|
m_mesh = model.m_mesh;
|
||||||
m_mesh->AddResourceReference();
|
m_materials = model.m_materials;
|
||||||
|
|
||||||
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
|
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
|
||||||
m_skeleton = model.m_skeleton;
|
m_skeleton = model.m_skeleton;
|
||||||
|
|
||||||
// Nous n'avons des matériaux que si nous avons un mesh
|
|
||||||
for (const NzMaterial* material : m_materials)
|
|
||||||
material->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -314,22 +306,11 @@ void NzModel::Reset()
|
||||||
|
|
||||||
if (m_mesh)
|
if (m_mesh)
|
||||||
{
|
{
|
||||||
m_mesh->RemoveResourceReference();
|
m_animation.Reset();
|
||||||
m_mesh = nullptr;
|
m_mesh.Reset();
|
||||||
|
m_materials.clear();
|
||||||
|
|
||||||
m_skeleton.Destroy();
|
m_skeleton.Destroy();
|
||||||
|
|
||||||
if (m_animation)
|
|
||||||
{
|
|
||||||
m_animation->RemoveResourceReference();
|
|
||||||
m_animation = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nous n'avons des matériaux que si nous avons un mesh
|
|
||||||
for (const NzMaterial* material : m_materials)
|
|
||||||
material->RemoveResourceReference();
|
|
||||||
|
|
||||||
m_materials.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -367,7 +348,6 @@ bool NzModel::SetAnimation(NzAnimation* animation)
|
||||||
m_animation = animation;
|
m_animation = animation;
|
||||||
if (m_animation)
|
if (m_animation)
|
||||||
{
|
{
|
||||||
m_animation->AddResourceReference();
|
|
||||||
m_currentFrame = 0;
|
m_currentFrame = 0;
|
||||||
m_interpolation = 0.f;
|
m_interpolation = 0.f;
|
||||||
|
|
||||||
|
|
@ -394,14 +374,10 @@ void NzModel::SetMaterial(unsigned int matIndex, NzMaterial* material)
|
||||||
|
|
||||||
unsigned int index = m_skin*m_matCount + matIndex;
|
unsigned int index = m_skin*m_matCount + matIndex;
|
||||||
|
|
||||||
m_materials[index]->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (material)
|
if (material)
|
||||||
m_materials[index] = material;
|
m_materials[index] = material;
|
||||||
else
|
else
|
||||||
m_materials[index] = NzMaterial::GetDefault();
|
m_materials[index] = NzMaterial::GetDefault();
|
||||||
|
|
||||||
m_materials[index]->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzModel::SetMaterial(unsigned int skinIndex, unsigned int matIndex, NzMaterial* material)
|
void NzModel::SetMaterial(unsigned int skinIndex, unsigned int matIndex, NzMaterial* material)
|
||||||
|
|
@ -422,14 +398,10 @@ void NzModel::SetMaterial(unsigned int skinIndex, unsigned int matIndex, NzMater
|
||||||
|
|
||||||
unsigned int index = skinIndex*m_matCount + matIndex;
|
unsigned int index = skinIndex*m_matCount + matIndex;
|
||||||
|
|
||||||
m_materials[index]->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (material)
|
if (material)
|
||||||
m_materials[index] = material;
|
m_materials[index] = material;
|
||||||
else
|
else
|
||||||
m_materials[index] = NzMaterial::GetDefault();
|
m_materials[index] = NzMaterial::GetDefault();
|
||||||
|
|
||||||
m_materials[index]->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzModel::SetMesh(NzMesh* mesh, const NzModelParameters& modelParameters)
|
void NzModel::SetMesh(NzMesh* mesh, const NzModelParameters& modelParameters)
|
||||||
|
|
@ -440,7 +412,6 @@ void NzModel::SetMesh(NzMesh* mesh, const NzModelParameters& modelParameters)
|
||||||
{
|
{
|
||||||
m_boundingBoxUpdated = false;
|
m_boundingBoxUpdated = false;
|
||||||
m_mesh = mesh;
|
m_mesh = mesh;
|
||||||
m_mesh->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
|
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
|
||||||
m_skeleton = *mesh->GetSkeleton(); // Copie du squelette template
|
m_skeleton = *mesh->GetSkeleton(); // Copie du squelette template
|
||||||
|
|
@ -462,7 +433,7 @@ void NzModel::SetMesh(NzMesh* mesh, const NzModelParameters& modelParameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_matCount = mesh->GetMaterialCount();
|
m_matCount = mesh->GetMaterialCount();
|
||||||
m_materials.resize(m_matCount, NzMaterial::GetDefault());
|
m_materials.reserve(m_matCount);
|
||||||
if (modelParameters.loadMaterials)
|
if (modelParameters.loadMaterials)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < m_matCount; ++i)
|
for (unsigned int i = 0; i < m_matCount; ++i)
|
||||||
|
|
@ -474,16 +445,17 @@ void NzModel::SetMesh(NzMesh* mesh, const NzModelParameters& modelParameters)
|
||||||
if (material->LoadFromFile(mat, modelParameters.material))
|
if (material->LoadFromFile(mat, modelParameters.material))
|
||||||
{
|
{
|
||||||
material->SetPersistent(false, false); // Pas de vérification des références car nous n'y avons pas encore accroché de référence
|
material->SetPersistent(false, false); // Pas de vérification des références car nous n'y avons pas encore accroché de référence
|
||||||
m_materials[i] = material.release();
|
m_materials.push_back(material.release());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
NazaraWarning("Failed to load material #" + NzString::Number(i));
|
NazaraWarning("Failed to load material #" + NzString::Number(i));
|
||||||
|
|
||||||
|
m_materials.push_back(NzMaterial::GetDefault());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const NzMaterial* material : m_materials)
|
|
||||||
material->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,6 @@ NzSoundEmitter(sound)
|
||||||
NzSound::~NzSound()
|
NzSound::~NzSound()
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
if (m_buffer)
|
|
||||||
m_buffer->RemoveResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzSound::EnableLooping(bool loop)
|
void NzSound::EnableLooping(bool loop)
|
||||||
|
|
@ -155,16 +152,10 @@ void NzSound::SetBuffer(const NzSoundBuffer* buffer)
|
||||||
|
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
if (m_buffer)
|
|
||||||
m_buffer->RemoveResourceReference();
|
|
||||||
|
|
||||||
m_buffer = buffer;
|
m_buffer = buffer;
|
||||||
|
|
||||||
if (m_buffer)
|
if (m_buffer)
|
||||||
{
|
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
alSourcei(m_source, AL_BUFFER, m_buffer->GetOpenALBuffer());
|
alSourcei(m_source, AL_BUFFER, m_buffer->GetOpenALBuffer());
|
||||||
}
|
|
||||||
else
|
else
|
||||||
alSourcei(m_source, AL_BUFFER, AL_NONE);
|
alSourcei(m_source, AL_BUFFER, AL_NONE);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ bool NzResource::IsPersistent() const
|
||||||
return m_resourcePersistent;
|
return m_resourcePersistent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzResource::RemoveResourceListener(NzResourceListener* listener) const
|
bool NzResource::RemoveResourceListener(NzResourceListener* listener) const
|
||||||
{
|
{
|
||||||
NazaraMutexLock(m_mutex);
|
NazaraMutexLock(m_mutex);
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ void NzResource::RemoveResourceListener(NzResourceListener* listener) const
|
||||||
if (m_resourceReferenceCount == 0)
|
if (m_resourceReferenceCount == 0)
|
||||||
{
|
{
|
||||||
NazaraError("Impossible to remove reference (Ref. counter is already 0)");
|
NazaraError("Impossible to remove reference (Ref. counter is already 0)");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -90,14 +90,18 @@ void NzResource::RemoveResourceListener(NzResourceListener* listener) const
|
||||||
{
|
{
|
||||||
NazaraMutexUnlock(m_mutex);
|
NazaraMutexUnlock(m_mutex);
|
||||||
delete this;
|
delete this;
|
||||||
|
|
||||||
|
return true; // On vient d'être supprimé
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NazaraMutexUnlock(m_mutex);
|
NazaraMutexUnlock(m_mutex);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzResource::RemoveResourceReference() const
|
bool NzResource::RemoveResourceReference() const
|
||||||
{
|
{
|
||||||
NazaraMutexLock(m_mutex);
|
NazaraMutexLock(m_mutex);
|
||||||
|
|
||||||
|
|
@ -105,7 +109,7 @@ void NzResource::RemoveResourceReference() const
|
||||||
if (m_resourceReferenceCount == 0)
|
if (m_resourceReferenceCount == 0)
|
||||||
{
|
{
|
||||||
NazaraError("Impossible to remove reference (Ref. counter is already 0)");
|
NazaraError("Impossible to remove reference (Ref. counter is already 0)");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -113,10 +117,14 @@ void NzResource::RemoveResourceReference() const
|
||||||
{
|
{
|
||||||
NazaraMutexUnlock(m_mutex);
|
NazaraMutexUnlock(m_mutex);
|
||||||
delete this;
|
delete this;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NazaraMutexUnlock(m_mutex);
|
NazaraMutexUnlock(m_mutex);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,7 @@ bool NzMaterialParams::IsValid() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzMaterial::NzMaterial() :
|
NzMaterial::NzMaterial()
|
||||||
m_customShader(nullptr),
|
|
||||||
m_diffuseMap(nullptr),
|
|
||||||
m_heightMap(nullptr),
|
|
||||||
m_normalMap(nullptr),
|
|
||||||
m_specularMap(nullptr)
|
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
@ -27,28 +22,12 @@ m_specularMap(nullptr)
|
||||||
NzMaterial::NzMaterial(const NzMaterial& material) :
|
NzMaterial::NzMaterial(const NzMaterial& material) :
|
||||||
NzResource()
|
NzResource()
|
||||||
{
|
{
|
||||||
std::memcpy(this, &material, sizeof(NzMaterial)); // Autorisé dans notre cas, et plus rapide
|
Copy(material);
|
||||||
|
|
||||||
// Cependant comme nous sommes une entité à part nous devons ajouter les références aux ressources
|
|
||||||
if (m_customShader)
|
|
||||||
m_customShader->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_diffuseMap)
|
|
||||||
m_diffuseMap->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_heightMap)
|
|
||||||
m_heightMap->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_normalMap)
|
|
||||||
m_normalMap->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_specularMap)
|
|
||||||
m_specularMap->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzMaterial::NzMaterial(NzMaterial&& material)
|
NzMaterial::NzMaterial(NzMaterial&& material)
|
||||||
{
|
{
|
||||||
std::memcpy(this, &material, sizeof(NzMaterial)); // Autorisé dans notre cas, et plus rapide
|
Copy(material);
|
||||||
|
|
||||||
// Nous "volons" la référence du matériau
|
// Nous "volons" la référence du matériau
|
||||||
material.m_customShader = nullptr;
|
material.m_customShader = nullptr;
|
||||||
|
|
@ -58,24 +37,6 @@ NzMaterial::NzMaterial(NzMaterial&& material)
|
||||||
material.m_specularMap = nullptr;
|
material.m_specularMap = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzMaterial::~NzMaterial()
|
|
||||||
{
|
|
||||||
if (m_customShader)
|
|
||||||
m_customShader->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_diffuseMap)
|
|
||||||
m_diffuseMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_heightMap)
|
|
||||||
m_heightMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_normalMap)
|
|
||||||
m_normalMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_specularMap)
|
|
||||||
m_specularMap->RemoveResourceReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzMaterial::Apply(const NzShader* shader) const
|
void NzMaterial::Apply(const NzShader* shader) const
|
||||||
{
|
{
|
||||||
int ambientColorLocation = shader->GetUniformLocation("MaterialAmbient");
|
int ambientColorLocation = shader->GetUniformLocation("MaterialAmbient");
|
||||||
|
|
@ -346,35 +307,11 @@ bool NzMaterial::LoadFromStream(NzInputStream& stream, const NzMaterialParams& p
|
||||||
|
|
||||||
void NzMaterial::Reset()
|
void NzMaterial::Reset()
|
||||||
{
|
{
|
||||||
if (m_customShader)
|
m_customShader.Reset();
|
||||||
{
|
m_diffuseMap.Reset();
|
||||||
m_customShader->RemoveResourceReference();
|
m_heightMap.Reset();
|
||||||
m_customShader = nullptr;
|
m_normalMap.Reset();
|
||||||
}
|
m_specularMap.Reset();
|
||||||
|
|
||||||
if (m_diffuseMap)
|
|
||||||
{
|
|
||||||
m_diffuseMap->RemoveResourceReference();
|
|
||||||
m_diffuseMap = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_heightMap)
|
|
||||||
{
|
|
||||||
m_heightMap->RemoveResourceReference();
|
|
||||||
m_heightMap = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_normalMap)
|
|
||||||
{
|
|
||||||
m_normalMap->RemoveResourceReference();
|
|
||||||
m_normalMap = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_specularMap)
|
|
||||||
{
|
|
||||||
m_specularMap->RemoveResourceReference();
|
|
||||||
m_specularMap = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_alphaBlendingEnabled = false;
|
m_alphaBlendingEnabled = false;
|
||||||
m_ambientColor = NzColor(128, 128, 128);
|
m_ambientColor = NzColor(128, 128, 128);
|
||||||
|
|
@ -402,15 +339,7 @@ void NzMaterial::SetAmbientColor(const NzColor& ambient)
|
||||||
|
|
||||||
void NzMaterial::SetCustomShader(const NzShader* shader)
|
void NzMaterial::SetCustomShader(const NzShader* shader)
|
||||||
{
|
{
|
||||||
if (m_customShader != shader)
|
m_customShader = shader;
|
||||||
{
|
|
||||||
if (m_customShader)
|
|
||||||
m_customShader->RemoveResourceReference();
|
|
||||||
|
|
||||||
m_customShader = shader;
|
|
||||||
if (m_customShader)
|
|
||||||
m_customShader->AddResourceReference();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMaterial::SetDiffuseColor(const NzColor& diffuse)
|
void NzMaterial::SetDiffuseColor(const NzColor& diffuse)
|
||||||
|
|
@ -420,21 +349,11 @@ void NzMaterial::SetDiffuseColor(const NzColor& diffuse)
|
||||||
|
|
||||||
void NzMaterial::SetDiffuseMap(NzTexture* map)
|
void NzMaterial::SetDiffuseMap(NzTexture* map)
|
||||||
{
|
{
|
||||||
if (m_diffuseMap != map)
|
m_diffuseMap = map;
|
||||||
{
|
if (m_diffuseMap)
|
||||||
if (m_diffuseMap)
|
m_shaderFlags |= nzShaderFlags_DiffuseMapping;
|
||||||
{
|
else
|
||||||
m_diffuseMap->RemoveResourceReference();
|
m_shaderFlags &= ~nzShaderFlags_DiffuseMapping;
|
||||||
m_shaderFlags &= ~nzShaderFlags_DiffuseMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_diffuseMap = map;
|
|
||||||
if (m_diffuseMap)
|
|
||||||
{
|
|
||||||
m_diffuseMap->AddResourceReference();
|
|
||||||
m_shaderFlags |= nzShaderFlags_DiffuseMapping;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMaterial::SetDiffuseSampler(const NzTextureSampler& sampler)
|
void NzMaterial::SetDiffuseSampler(const NzTextureSampler& sampler)
|
||||||
|
|
@ -459,34 +378,16 @@ void NzMaterial::SetFaceFilling(nzFaceFilling filling)
|
||||||
|
|
||||||
void NzMaterial::SetHeightMap(NzTexture* map)
|
void NzMaterial::SetHeightMap(NzTexture* map)
|
||||||
{
|
{
|
||||||
if (m_heightMap != map)
|
m_heightMap = map;
|
||||||
{
|
|
||||||
if (m_heightMap)
|
|
||||||
m_heightMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
m_heightMap = map;
|
|
||||||
if (m_heightMap)
|
|
||||||
m_heightMap->AddResourceReference();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMaterial::SetNormalMap(NzTexture* map)
|
void NzMaterial::SetNormalMap(NzTexture* map)
|
||||||
{
|
{
|
||||||
if (m_normalMap != map)
|
m_normalMap = map;
|
||||||
{
|
if (m_normalMap)
|
||||||
if (m_normalMap)
|
m_shaderFlags |= nzShaderFlags_NormalMapping;
|
||||||
{
|
else
|
||||||
m_normalMap->RemoveResourceReference();
|
m_shaderFlags &= ~nzShaderFlags_NormalMapping;
|
||||||
m_shaderFlags &= ~nzShaderFlags_NormalMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_normalMap = map;
|
|
||||||
if (m_normalMap)
|
|
||||||
{
|
|
||||||
m_normalMap->AddResourceReference();
|
|
||||||
m_shaderFlags |= nzShaderFlags_NormalMapping;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMaterial::SetShininess(float shininess)
|
void NzMaterial::SetShininess(float shininess)
|
||||||
|
|
@ -501,21 +402,11 @@ void NzMaterial::SetSpecularColor(const NzColor& specular)
|
||||||
|
|
||||||
void NzMaterial::SetSpecularMap(NzTexture* map)
|
void NzMaterial::SetSpecularMap(NzTexture* map)
|
||||||
{
|
{
|
||||||
if (m_specularMap != map)
|
m_specularMap = map;
|
||||||
{
|
if (m_specularMap)
|
||||||
if (m_specularMap)
|
m_shaderFlags |= nzShaderFlags_SpecularMapping;
|
||||||
{
|
else
|
||||||
m_specularMap->RemoveResourceReference();
|
m_shaderFlags &= ~nzShaderFlags_SpecularMapping;
|
||||||
m_shaderFlags &= ~nzShaderFlags_SpecularMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_specularMap = map;
|
|
||||||
if (m_specularMap)
|
|
||||||
{
|
|
||||||
m_specularMap->AddResourceReference();
|
|
||||||
m_shaderFlags |= nzShaderFlags_SpecularMapping;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMaterial::SetSpecularSampler(const NzTextureSampler& sampler)
|
void NzMaterial::SetSpecularSampler(const NzTextureSampler& sampler)
|
||||||
|
|
@ -535,60 +426,14 @@ void NzMaterial::SetZTestCompare(nzRendererComparison compareFunc)
|
||||||
|
|
||||||
NzMaterial& NzMaterial::operator=(const NzMaterial& material)
|
NzMaterial& NzMaterial::operator=(const NzMaterial& material)
|
||||||
{
|
{
|
||||||
if (m_customShader)
|
Copy(material);
|
||||||
m_customShader->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_diffuseMap)
|
|
||||||
m_diffuseMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_heightMap)
|
|
||||||
m_heightMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_normalMap)
|
|
||||||
m_normalMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_specularMap)
|
|
||||||
m_specularMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
std::memcpy(this, &material, sizeof(NzMaterial)); // Autorisé dans notre cas, et plus rapide
|
|
||||||
|
|
||||||
// Cependant comme nous sommes une entité à part nous devons ajouter les références aux ressources
|
|
||||||
if (m_customShader)
|
|
||||||
m_customShader->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_diffuseMap)
|
|
||||||
m_diffuseMap->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_heightMap)
|
|
||||||
m_heightMap->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_normalMap)
|
|
||||||
m_normalMap->AddResourceReference();
|
|
||||||
|
|
||||||
if (m_specularMap)
|
|
||||||
m_specularMap->AddResourceReference();
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzMaterial& NzMaterial::operator=(NzMaterial&& material)
|
NzMaterial& NzMaterial::operator=(NzMaterial&& material)
|
||||||
{
|
{
|
||||||
if (m_customShader)
|
Copy(material);
|
||||||
m_customShader->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_diffuseMap)
|
|
||||||
m_diffuseMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_heightMap)
|
|
||||||
m_heightMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_normalMap)
|
|
||||||
m_normalMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (m_specularMap)
|
|
||||||
m_specularMap->RemoveResourceReference();
|
|
||||||
|
|
||||||
std::memcpy(this, &material, sizeof(NzMaterial)); // Autorisé dans notre cas, et plus rapide
|
|
||||||
|
|
||||||
// Comme ça nous volons la référence du matériau
|
// Comme ça nous volons la référence du matériau
|
||||||
material.m_customShader = nullptr;
|
material.m_customShader = nullptr;
|
||||||
|
|
@ -618,4 +463,28 @@ NzMaterial* NzMaterial::GetDefault()
|
||||||
return &defaultMaterial;
|
return &defaultMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzMaterial::Copy(const NzMaterial& material)
|
||||||
|
{
|
||||||
|
m_customShader.Reset();
|
||||||
|
m_diffuseMap.Reset();
|
||||||
|
m_heightMap.Reset();
|
||||||
|
m_normalMap.Reset();
|
||||||
|
m_specularMap.Reset();
|
||||||
|
|
||||||
|
std::memcpy(this, &material, sizeof(NzMaterial)); // Autorisé dans notre cas, et bien plus rapide
|
||||||
|
|
||||||
|
// Ensuite une petite astuce pour récupérer correctement les références
|
||||||
|
m_customShader.Release();
|
||||||
|
m_diffuseMap.Release();
|
||||||
|
m_heightMap.Release();
|
||||||
|
m_normalMap.Release();
|
||||||
|
m_specularMap.Release();
|
||||||
|
|
||||||
|
m_customShader = material.m_customShader;
|
||||||
|
m_diffuseMap = material.m_diffuseMap;
|
||||||
|
m_heightMap = material.m_heightMap;
|
||||||
|
m_normalMap = material.m_normalMap;
|
||||||
|
m_specularMap = material.m_specularMap;
|
||||||
|
}
|
||||||
|
|
||||||
NzMaterialLoader::LoaderList NzMaterial::s_loaders;
|
NzMaterialLoader::LoaderList NzMaterial::s_loaders;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::unordered_map<nzUInt32, NzShader*> s_shaders;
|
std::unordered_map<nzUInt32, NzResourceRef<NzShader>> s_shaders;
|
||||||
|
|
||||||
NzString BuildFragmentShaderSource(nzUInt32 flags)
|
NzString BuildFragmentShaderSource(nzUInt32 flags)
|
||||||
{
|
{
|
||||||
|
|
@ -471,7 +471,6 @@ const NzShader* NzShaderBuilder::Get(nzUInt32 flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
s_shaders[flags] = shader;
|
s_shaders[flags] = shader;
|
||||||
shader->AddResourceReference();
|
|
||||||
|
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
@ -489,15 +488,11 @@ bool NzShaderBuilder::Initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
s_shaders[0] = shader;
|
s_shaders[0] = shader;
|
||||||
shader->AddResourceReference();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzShaderBuilder::Uninitialize()
|
void NzShaderBuilder::Uninitialize()
|
||||||
{
|
{
|
||||||
for (auto it : s_shaders)
|
|
||||||
it.second->RemoveResourceReference();
|
|
||||||
|
|
||||||
s_shaders.clear();
|
s_shaders.clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ m_startIndex(startIndex)
|
||||||
throw std::runtime_error("Constructor failed");
|
throw std::runtime_error("Constructor failed");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,7 +37,6 @@ m_indexCount(length),
|
||||||
m_startIndex(0)
|
m_startIndex(0)
|
||||||
{
|
{
|
||||||
m_buffer = new NzBuffer(nzBufferType_Index, length, (largeIndices) ? 4 : 2, storage, usage);
|
m_buffer = new NzBuffer(nzBufferType_Index, length, (largeIndices) ? 4 : 2, storage, usage);
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,23 +54,15 @@ m_startIndex(indexBuffer.m_startIndex)
|
||||||
NzBuffer* buffer = indexBuffer.m_buffer;
|
NzBuffer* buffer = indexBuffer.m_buffer;
|
||||||
|
|
||||||
m_buffer = new NzBuffer(nzBufferType_Index, buffer->GetLength(), buffer->GetSize(), buffer->GetStorage(), buffer->GetUsage());
|
m_buffer = new NzBuffer(nzBufferType_Index, buffer->GetLength(), buffer->GetSize(), buffer->GetStorage(), buffer->GetUsage());
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
m_buffer->CopyContent(*indexBuffer.m_buffer);
|
m_buffer->CopyContent(*indexBuffer.m_buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_buffer = indexBuffer.m_buffer;
|
m_buffer = indexBuffer.m_buffer;
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NzIndexBuffer::~NzIndexBuffer()
|
NzIndexBuffer::~NzIndexBuffer() = default;
|
||||||
{
|
|
||||||
if (m_buffer)
|
|
||||||
m_buffer->RemoveResourceReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzIndexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
bool NzIndexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ struct NzSkeletalMeshImpl
|
||||||
std::vector<NzWeight> weights;
|
std::vector<NzWeight> weights;
|
||||||
NzCubef aabb;
|
NzCubef aabb;
|
||||||
nzUInt8* bindPoseBuffer;
|
nzUInt8* bindPoseBuffer;
|
||||||
const NzIndexBuffer* indexBuffer = nullptr;
|
NzIndexBufferConstRef indexBuffer;
|
||||||
unsigned int vertexCount;
|
unsigned int vertexCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -401,11 +401,5 @@ void NzSkeletalMesh::Skin(NzMeshVertex* outputBuffer, const NzSkeleton* skeleton
|
||||||
|
|
||||||
void NzSkeletalMesh::SetIndexBuffer(const NzIndexBuffer* indexBuffer)
|
void NzSkeletalMesh::SetIndexBuffer(const NzIndexBuffer* indexBuffer)
|
||||||
{
|
{
|
||||||
if (m_impl->indexBuffer)
|
|
||||||
m_impl->indexBuffer->RemoveResourceReference();
|
|
||||||
|
|
||||||
if (indexBuffer)
|
|
||||||
indexBuffer->AddResourceReference();
|
|
||||||
|
|
||||||
m_impl->indexBuffer = indexBuffer;
|
m_impl->indexBuffer = indexBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,6 @@ m_vertexCount(vertexCount)
|
||||||
throw std::invalid_argument("Invalid vertex declaration");
|
throw std::invalid_argument("Invalid vertex declaration");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
m_vertexDeclaration->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzVertexBuffer::NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzBufferStorage storage, nzBufferUsage usage) :
|
NzVertexBuffer::NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzBufferStorage storage, nzBufferUsage usage) :
|
||||||
|
|
@ -49,9 +46,7 @@ m_vertexCount(length)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_buffer = new NzBuffer(nzBufferType_Vertex, length, vertexDeclaration->GetStride(nzElementStream_VertexData), storage, usage);
|
m_buffer = new NzBuffer(nzBufferType_Vertex, length, vertexDeclaration->GetStride(nzElementStream_VertexData), storage, usage);
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
m_vertexDeclaration->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzVertexBuffer::NzVertexBuffer(const NzVertexBuffer& vertexBuffer) :
|
NzVertexBuffer::NzVertexBuffer(const NzVertexBuffer& vertexBuffer) :
|
||||||
|
|
@ -66,24 +61,14 @@ m_vertexCount(vertexBuffer.m_vertexCount)
|
||||||
NzBuffer* buffer = vertexBuffer.m_buffer;
|
NzBuffer* buffer = vertexBuffer.m_buffer;
|
||||||
|
|
||||||
m_buffer = new NzBuffer(nzBufferType_Vertex, buffer->GetLength(), buffer->GetSize(), buffer->GetStorage(), buffer->GetUsage());
|
m_buffer = new NzBuffer(nzBufferType_Vertex, buffer->GetLength(), buffer->GetSize(), buffer->GetStorage(), buffer->GetUsage());
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
m_buffer->CopyContent(*vertexBuffer.m_buffer);
|
m_buffer->CopyContent(*vertexBuffer.m_buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_buffer = vertexBuffer.m_buffer;
|
m_buffer = vertexBuffer.m_buffer;
|
||||||
m_buffer->AddResourceReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_vertexDeclaration->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzVertexBuffer::~NzVertexBuffer()
|
NzVertexBuffer::~NzVertexBuffer() = default;
|
||||||
{
|
|
||||||
m_buffer->RemoveResourceReference();
|
|
||||||
m_vertexDeclaration->RemoveResourceReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzVertexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
bool NzVertexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NzSubMesh* m_subMesh;
|
NzSubMeshRef m_subMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkeletalMeshVertexMapper : public SubMeshVertexMapper
|
class SkeletalMeshVertexMapper : public SubMeshVertexMapper
|
||||||
|
|
@ -63,13 +63,10 @@ namespace
|
||||||
m_mesh(subMesh)
|
m_mesh(subMesh)
|
||||||
{
|
{
|
||||||
m_vertices = reinterpret_cast<NzMeshVertex*>(m_mesh->GetBindPoseBuffer());
|
m_vertices = reinterpret_cast<NzMeshVertex*>(m_mesh->GetBindPoseBuffer());
|
||||||
|
|
||||||
m_mesh->AddResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~SkeletalMeshVertexMapper() noexcept
|
virtual ~SkeletalMeshVertexMapper() noexcept
|
||||||
{
|
{
|
||||||
m_mesh->RemoveResourceReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzVector3f GetNormal(unsigned int i) const
|
NzVector3f GetNormal(unsigned int i) const
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue