From 39fc2a426b0b3b0fef2fe199ec55dbde0f6fdf46 Mon Sep 17 00:00:00 2001 From: hybrid Date: Sat, 8 Sep 2007 22:37:57 +0000 Subject: [PATCH] Avoid destructor on md3 substructures which causes crash due to non-constructed array elements. Fixed color writing in irr mesh writer. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@928 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/IAnimatedMeshMD3.h | 6 ++++-- include/quaternion.h | 9 +++++++++ source/Irrlicht/CAnimatedMeshMD3.h | 4 ++-- source/Irrlicht/CIrrMeshWriter.cpp | 6 +++--- source/Irrlicht/CNullDriver.cpp | 2 +- source/Irrlicht/COpenGLSLMaterialRenderer.h | 1 - 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/IAnimatedMeshMD3.h b/include/IAnimatedMeshMD3.h index f20bf848..1eb9afd7 100644 --- a/include/IAnimatedMeshMD3.h +++ b/include/IAnimatedMeshMD3.h @@ -180,10 +180,10 @@ namespace scene } // construct from a position and euler angles in degrees - SMD3QuaterionTag ( const core::vector3df&pos, const core::vector3df &angle ) + SMD3QuaterionTag ( const core::vector3df &pos, const core::vector3df &angle ) { position = pos; - rotation.set ( angle.X * core::DEGTORAD, angle.Y * core::DEGTORAD, angle.Z * core::DEGTORAD ); + rotation.set ( angle * core::DEGTORAD ); } core::stringc Name; @@ -199,6 +199,8 @@ namespace scene // holds a assoziative list of named quaternions struct SMD3QuaterionTagList : public virtual IReferenceCounted { + ~SMD3QuaterionTagList() {} + SMD3QuaterionTag* get ( const core::stringc& name ) { SMD3QuaterionTag search ( name ); diff --git a/include/quaternion.h b/include/quaternion.h index 68fb0ced..0fcb4ad3 100644 --- a/include/quaternion.h +++ b/include/quaternion.h @@ -71,6 +71,9 @@ class quaternion //! sets new quaternion based on euler angles (radians) inline void set(f32 x, f32 y, f32 z); + //! sets new quaternion based on euler angles (radians) + inline void set(const core::vector3df& vec); + //! normalizes the quaternion inline quaternion& normalize(); @@ -397,6 +400,12 @@ inline void quaternion::set(f32 x, f32 y, f32 z) normalize(); } +//! sets new quaternion based on euler angles +inline void quaternion::set(const core::vector3df& vec) +{ + set(vec.X, vec.Y, vec.Z); +} + //! normalizes the quaternion inline quaternion& quaternion::normalize() { diff --git a/source/Irrlicht/CAnimatedMeshMD3.h b/source/Irrlicht/CAnimatedMeshMD3.h index a692dfb8..e27b4f95 100644 --- a/source/Irrlicht/CAnimatedMeshMD3.h +++ b/source/Irrlicht/CAnimatedMeshMD3.h @@ -79,8 +79,8 @@ namespace scene private: - //! animates one frame - inline void Animate (u32 frame); + //! animates one frame + inline void Animate (u32 frame); video::SMaterial Material; diff --git a/source/Irrlicht/CIrrMeshWriter.cpp b/source/Irrlicht/CIrrMeshWriter.cpp index 57ac6cf5..93761c7a 100644 --- a/source/Irrlicht/CIrrMeshWriter.cpp +++ b/source/Irrlicht/CIrrMeshWriter.cpp @@ -184,7 +184,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) str += getVectorAsStringLine(vtx[j].Normal); char tmp[12]; - sprintf(tmp, " %08x ", vtx[j].Color); + sprintf(tmp, " %08x ", vtx[j].Color.color); str += tmp; str += getVectorAsStringLine(vtx[j].TCoords); @@ -204,7 +204,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) str += getVectorAsStringLine(vtx[j].Normal); char tmp[12]; - sprintf(tmp, " %08x ", vtx[j].Color); + sprintf(tmp, " %08x ", vtx[j].Color.color); str += tmp; str += getVectorAsStringLine(vtx[j].TCoords); @@ -226,7 +226,7 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer) str += getVectorAsStringLine(vtx[j].Normal); char tmp[12]; - sprintf(tmp, " %08x ", vtx[j].Color); + sprintf(tmp, " %08x ", vtx[j].Color.color); str += tmp; str += getVectorAsStringLine(vtx[j].TCoords); diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index a83a4600..18244d73 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -281,7 +281,7 @@ ITexture* CNullDriver::getTexture(const c8* filename) if (texture) { addTexture(texture); - texture->drop(); // drop it becaus we created it, one grab too much + texture->drop(); // drop it because we created it, one grab too much } } else diff --git a/source/Irrlicht/COpenGLSLMaterialRenderer.h b/source/Irrlicht/COpenGLSLMaterialRenderer.h index 2f2d6114..19afebf0 100644 --- a/source/Irrlicht/COpenGLSLMaterialRenderer.h +++ b/source/Irrlicht/COpenGLSLMaterialRenderer.h @@ -41,7 +41,6 @@ namespace video class COpenGLDriver; class IShaderConstantSetCallBack; -class IMaterialRenderer; //! Class for using GLSL shaders with OpenGL //! Please note: This renderer implements its own IMaterialRendererServices