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
This commit is contained in:
cutealien 2022-04-11 14:36:49 +00:00
parent 64fc9113fc
commit 71e9798d2a
10 changed files with 482 additions and 375 deletions

@ -1,5 +1,6 @@
-------------------------- --------------------------
Changes in 1.9 (not yet released) 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 - 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). - 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. - vector3d scalar operator/ and operator/= no longer multiply by the inverse but use the expected division.

@ -114,6 +114,12 @@ namespace scene
return PrimitiveType; return PrimitiveType;
} }
//! Returns type of the class implementing the IMeshBuffer
virtual EMESH_BUFFER_TYPE getType() const IRR_OVERRIDE
{
return EMBT_DYNAMIC;
}
video::SMaterial Material; video::SMaterial Material;
core::aabbox3d<f32> BoundingBox; core::aabbox3d<f32> BoundingBox;
//! Primitive type used for rendering (triangles, lines, ...) //! Primitive type used for rendering (triangles, lines, ...)

@ -286,6 +286,17 @@ namespace scene
/** This shouldn't be used for anything outside the VideoDriver. */ /** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID_Index() const IRR_OVERRIDE {return ChangedID_Index;} 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_Vertex;
u32 ChangedID_Index; u32 ChangedID_Index;
@ -311,6 +322,25 @@ namespace scene
typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap; typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap;
//! Meshbuffer with vertices having tangents stored, e.g. for normal mapping //! Meshbuffer with vertices having tangents stored, e.g. for normal mapping
typedef CMeshBuffer<video::S3DVertexTangents> SMeshBufferTangents; typedef CMeshBuffer<video::S3DVertexTangents> SMeshBufferTangents;
//! partial specialization to return types
template <>
inline EMESH_BUFFER_TYPE CMeshBuffer<video::S3DVertex>::getTypeT() const
{
return EMBT_STANDARD;
}
template <>
inline EMESH_BUFFER_TYPE CMeshBuffer<video::S3DVertex2TCoords>::getTypeT() const
{
return EMBT_LIGHTMAP;
}
template <>
inline EMESH_BUFFER_TYPE CMeshBuffer<video::S3DVertexTangents>::getTypeT() const
{
return EMBT_TANGENTS;
}
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr

@ -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

@ -12,6 +12,7 @@
#include "SVertexIndex.h" #include "SVertexIndex.h"
#include "EHardwareBufferFlags.h" #include "EHardwareBufferFlags.h"
#include "EPrimitiveTypes.h" #include "EPrimitiveTypes.h"
#include "EMeshBufferTypes.h"
namespace irr namespace irr
{ {
@ -176,6 +177,14 @@ namespace scene
return 0; 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 } // end namespace scene

@ -226,6 +226,12 @@ namespace scene
/** This shouldn't be used for anything outside the VideoDriver. */ /** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID_Index() const IRR_OVERRIDE {return ChangedID_Index;} 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 //! Material of this meshBuffer
video::SMaterial Material; video::SMaterial Material;

@ -383,6 +383,12 @@ struct SSkinMeshBuffer : public IMeshBuffer
virtual u32 getChangedID_Index() const IRR_OVERRIDE {return ChangedID_Index;} 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. //! Call this after changing the positions of any vertex.
void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; } void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; }

File diff suppressed because it is too large Load Diff

@ -844,6 +844,7 @@
<ClInclude Include="..\..\include\EHardwareBufferFlags.h" /> <ClInclude Include="..\..\include\EHardwareBufferFlags.h" />
<ClInclude Include="..\..\include\EMaterialFlags.h" /> <ClInclude Include="..\..\include\EMaterialFlags.h" />
<ClInclude Include="..\..\include\EMaterialTypes.h" /> <ClInclude Include="..\..\include\EMaterialTypes.h" />
<ClInclude Include="..\..\include\EMeshBufferTypes.h" />
<ClInclude Include="..\..\include\EReadFileType.h" /> <ClInclude Include="..\..\include\EReadFileType.h" />
<ClInclude Include="..\..\include\EShaderTypes.h" /> <ClInclude Include="..\..\include\EShaderTypes.h" />
<ClInclude Include="..\..\include\fast_atof.h" /> <ClInclude Include="..\..\include\fast_atof.h" />

@ -1438,6 +1438,9 @@
<ClInclude Include="..\..\include\EDeviceTypes.h"> <ClInclude Include="..\..\include\EDeviceTypes.h">
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\include\EMeshBufferTypes.h">
<Filter>include\scene</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\changes.txt"> <None Include="..\..\changes.txt">