From 71e9798d2a9fafebc16c55f2207a3a0259be1baa Mon Sep 17 00:00:00 2001 From: cutealien Date: Mon, 11 Apr 2022 14:36:49 +0000 Subject: [PATCH] Add IMeshBuffer::getType Allows to find out which class a meshbuffer has. I used the same kind of style as ISceneNode::getType. So using four CC codes and virtual functions (instead of type variable). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6330 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + include/CDynamicMeshBuffer.h | 6 + include/CMeshBuffer.h | 30 + include/EMeshBufferTypes.h | 44 ++ include/IMeshBuffer.h | 9 + include/SSharedMeshBuffer.h | 6 + include/SSkinMeshBuffer.h | 6 + source/Irrlicht/Irrlicht-gcc.cbp | 733 ++++++++++--------- source/Irrlicht/Irrlicht10.0.vcxproj | 13 +- source/Irrlicht/Irrlicht10.0.vcxproj.filters | 9 +- 10 files changed, 482 insertions(+), 375 deletions(-) create mode 100644 include/EMeshBufferTypes.h diff --git a/changes.txt b/changes.txt index 91007b7..166e34a 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- Add IMeshBuffer::getType to allow finding out which class type a meshbuffer has (similar to ISceneNode::getType). - Add IGUIImage::flip to flip/mirror images - IBillboardSceneNode got functions to access meshbuffers. So uv-coordinates can now be modified directly (previously only possible via texture matrix). - vector3d scalar operator/ and operator/= no longer multiply by the inverse but use the expected division. diff --git a/include/CDynamicMeshBuffer.h b/include/CDynamicMeshBuffer.h index cb776d2..c0ee356 100644 --- a/include/CDynamicMeshBuffer.h +++ b/include/CDynamicMeshBuffer.h @@ -114,6 +114,12 @@ namespace scene return PrimitiveType; } + //! Returns type of the class implementing the IMeshBuffer + virtual EMESH_BUFFER_TYPE getType() const IRR_OVERRIDE + { + return EMBT_DYNAMIC; + } + video::SMaterial Material; core::aabbox3d BoundingBox; //! Primitive type used for rendering (triangles, lines, ...) diff --git a/include/CMeshBuffer.h b/include/CMeshBuffer.h index 9f7e215..22b1c9e 100644 --- a/include/CMeshBuffer.h +++ b/include/CMeshBuffer.h @@ -286,6 +286,17 @@ namespace scene /** This shouldn't be used for anything outside the VideoDriver. */ virtual u32 getChangedID_Index() const IRR_OVERRIDE {return ChangedID_Index;} + //! Returns type of the class implementing the IMeshBuffer + virtual EMESH_BUFFER_TYPE getType() const IRR_OVERRIDE + { + return getTypeT(); + } + + //! Returns type of the class implementing the IMeshBuffer for template specialization + // Minor note: Some compilers (VS) allow directly specializating the virtual function, + // but this will fail on other compilers (GCC). + EMESH_BUFFER_TYPE getTypeT() const; + u32 ChangedID_Vertex; u32 ChangedID_Index; @@ -311,6 +322,25 @@ namespace scene typedef CMeshBuffer SMeshBufferLightMap; //! Meshbuffer with vertices having tangents stored, e.g. for normal mapping typedef CMeshBuffer SMeshBufferTangents; + + //! partial specialization to return types + template <> + inline EMESH_BUFFER_TYPE CMeshBuffer::getTypeT() const + { + return EMBT_STANDARD; + } + template <> + inline EMESH_BUFFER_TYPE CMeshBuffer::getTypeT() const + { + return EMBT_LIGHTMAP; + } + template <> + inline EMESH_BUFFER_TYPE CMeshBuffer::getTypeT() const + { + return EMBT_TANGENTS; + } + + } // end namespace scene } // end namespace irr diff --git a/include/EMeshBufferTypes.h b/include/EMeshBufferTypes.h new file mode 100644 index 0000000..c9d5fc3 --- /dev/null +++ b/include/EMeshBufferTypes.h @@ -0,0 +1,44 @@ +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef IRR_E_MESH_BUFFER_TYPES_H_INCLUDED +#define IRR_E_MESH_BUFFER_TYPES_H_INCLUDED + +#include "irrTypes.h" + +namespace irr +{ +namespace scene +{ + + //! An enumeration for all types of built-in mesh buffers + /** Types are represented by a four character code instead + of simple numbers (easier to add external classes). */ + enum EMESH_BUFFER_TYPE + { + //! SMeshBuffer + EMBT_STANDARD = MAKE_IRR_ID('s','t','a','n'), + + //! SMeshBufferLightMap + EMBT_LIGHTMAP = MAKE_IRR_ID('l','i','g','h'), + + //! SMeshBufferTangents + EMBT_TANGENTS = MAKE_IRR_ID('t','a','n','g'), + + //! CDynamicMeshBuffer + EMBT_DYNAMIC = MAKE_IRR_ID('d','y','n','a'), + + // SSharedMeshBuffer + EMBT_SHARED = MAKE_IRR_ID('s','h','a','r'), + + // SSkinMeshBuffer + EMBT_SKIN = MAKE_IRR_ID('s','k','i','n'), + + //! Unknown class type + EMBT_UNKNOWN = MAKE_IRR_ID('u','n','k','n') + }; + +} // end namespace scene +} // end namespace irr + +#endif diff --git a/include/IMeshBuffer.h b/include/IMeshBuffer.h index 8b14177..5b43ffc 100644 --- a/include/IMeshBuffer.h +++ b/include/IMeshBuffer.h @@ -12,6 +12,7 @@ #include "SVertexIndex.h" #include "EHardwareBufferFlags.h" #include "EPrimitiveTypes.h" +#include "EMeshBufferTypes.h" namespace irr { @@ -176,6 +177,14 @@ namespace scene return 0; } + //! Returns type of the class implementing the IMeshBuffer + /** \return The class type of this meshbuffer. */ + virtual EMESH_BUFFER_TYPE getType() const + { + return EMBT_UNKNOWN; + } + + }; } // end namespace scene diff --git a/include/SSharedMeshBuffer.h b/include/SSharedMeshBuffer.h index 0a171be..b9d82e6 100644 --- a/include/SSharedMeshBuffer.h +++ b/include/SSharedMeshBuffer.h @@ -226,6 +226,12 @@ namespace scene /** This shouldn't be used for anything outside the VideoDriver. */ virtual u32 getChangedID_Index() const IRR_OVERRIDE {return ChangedID_Index;} + //! Returns type of the class implementing the IMeshBuffer + virtual EMESH_BUFFER_TYPE getType() const IRR_OVERRIDE + { + return EMBT_SHARED; + } + //! Material of this meshBuffer video::SMaterial Material; diff --git a/include/SSkinMeshBuffer.h b/include/SSkinMeshBuffer.h index 726deff..1e29889 100644 --- a/include/SSkinMeshBuffer.h +++ b/include/SSkinMeshBuffer.h @@ -383,6 +383,12 @@ struct SSkinMeshBuffer : public IMeshBuffer virtual u32 getChangedID_Index() const IRR_OVERRIDE {return ChangedID_Index;} + //! Returns type of the class implementing the IMeshBuffer + virtual EMESH_BUFFER_TYPE getType() const IRR_OVERRIDE + { + return EMBT_SKIN; + } + //! Call this after changing the positions of any vertex. void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; } diff --git a/source/Irrlicht/Irrlicht-gcc.cbp b/source/Irrlicht/Irrlicht-gcc.cbp index 2905dd0..08b38e8 100644 --- a/source/Irrlicht/Irrlicht-gcc.cbp +++ b/source/Irrlicht/Irrlicht-gcc.cbp @@ -8,8 +8,8 @@ @@ -397,199 +397,200 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1019,23 +1020,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -1044,277 +1045,277 @@ - + - + - + - - - + + + - + - + - + - - + + - + - + - + - + - + - + - + - - + + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - - + + - + - - - - - + + + + + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - - + + - - + + - - - + + + - + - - + + - - + + - - - + + + - + diff --git a/source/Irrlicht/Irrlicht10.0.vcxproj b/source/Irrlicht/Irrlicht10.0.vcxproj index c713a79..8de8ceb 100644 --- a/source/Irrlicht/Irrlicht10.0.vcxproj +++ b/source/Irrlicht/Irrlicht10.0.vcxproj @@ -844,6 +844,7 @@ + @@ -859,8 +860,8 @@ - - + + @@ -869,7 +870,7 @@ - + @@ -1035,7 +1036,7 @@ - + @@ -1194,7 +1195,7 @@ - + @@ -1461,7 +1462,7 @@ - + diff --git a/source/Irrlicht/Irrlicht10.0.vcxproj.filters b/source/Irrlicht/Irrlicht10.0.vcxproj.filters index b3f1068..a6adc9d 100644 --- a/source/Irrlicht/Irrlicht10.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht10.0.vcxproj.filters @@ -131,13 +131,13 @@ include - + include include - + include @@ -1371,7 +1371,7 @@ Irrlicht\video\Null - + include\core @@ -1438,6 +1438,9 @@ include + + include\scene +