mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-05 17:50:24 +02:00
Merging r6288 through r6336 from trunk to ogl-es branch
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6337 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@ -14,7 +14,7 @@ namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! Implementation of the IMeshBuffer interface for which can work with 16 and 32 bit indices as well as different vertex types
|
||||
class CDynamicMeshBuffer: public IDynamicMeshBuffer
|
||||
{
|
||||
public:
|
||||
@ -114,6 +114,46 @@ namespace scene
|
||||
return PrimitiveType;
|
||||
}
|
||||
|
||||
//! Returns type of the class implementing the IMeshBuffer
|
||||
virtual EMESH_BUFFER_TYPE getType() const IRR_OVERRIDE
|
||||
{
|
||||
return EMBT_DYNAMIC;
|
||||
}
|
||||
|
||||
//! Create copy of the meshbuffer
|
||||
virtual IMeshBuffer* createClone(int cloneFlags) const IRR_OVERRIDE
|
||||
{
|
||||
CDynamicMeshBuffer* clone = new CDynamicMeshBuffer(VertexBuffer->getType(), IndexBuffer->getType());
|
||||
|
||||
if (cloneFlags & ECF_VERTICES)
|
||||
{
|
||||
const u32 numVertices = VertexBuffer->size();
|
||||
clone->VertexBuffer->reallocate(numVertices);
|
||||
for ( u32 i=0; i<numVertices; ++i )
|
||||
{
|
||||
clone->VertexBuffer->push_back((*VertexBuffer)[i]);
|
||||
}
|
||||
clone->BoundingBox = BoundingBox;
|
||||
}
|
||||
|
||||
if (cloneFlags & ECF_INDICES)
|
||||
{
|
||||
const u32 numIndices = IndexBuffer->size();
|
||||
clone->IndexBuffer->reallocate(numIndices);
|
||||
for ( u32 i=0; i<numIndices; ++i )
|
||||
{
|
||||
clone->IndexBuffer->push_back((*IndexBuffer)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
clone->VertexBuffer->setHardwareMappingHint(VertexBuffer->getHardwareMappingHint());
|
||||
clone->IndexBuffer->setHardwareMappingHint(clone->IndexBuffer->getHardwareMappingHint());
|
||||
clone->Material = Material;
|
||||
clone->PrimitiveType = PrimitiveType;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
video::SMaterial Material;
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
//! Primitive type used for rendering (triangles, lines, ...)
|
||||
|
@ -12,7 +12,7 @@ namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
//! Template implementation of the IMeshBuffer interface
|
||||
//! Template implementation of the IMeshBuffer interface for 16-bit buffers
|
||||
template <class T>
|
||||
class CMeshBuffer : public IMeshBuffer
|
||||
{
|
||||
@ -193,8 +193,8 @@ namespace scene
|
||||
Vertices.reallocate(vertexCount+numVertices);
|
||||
for (i=0; i<numVertices; ++i)
|
||||
{
|
||||
Vertices.push_back(reinterpret_cast<const T*>(vertices)[i]);
|
||||
BoundingBox.addInternalPoint(reinterpret_cast<const T*>(vertices)[i].Pos);
|
||||
Vertices.push_back(static_cast<const T*>(vertices)[i]);
|
||||
BoundingBox.addInternalPoint(static_cast<const T*>(vertices)[i].Pos);
|
||||
}
|
||||
|
||||
Indices.reallocate(getIndexCount()+numIndices);
|
||||
@ -286,6 +286,41 @@ 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();
|
||||
}
|
||||
|
||||
//! Create copy of the meshbuffer
|
||||
virtual IMeshBuffer* createClone(int cloneFlags) const IRR_OVERRIDE
|
||||
{
|
||||
CMeshBuffer<T> * clone = new CMeshBuffer<T>();
|
||||
|
||||
if (cloneFlags & ECF_VERTICES)
|
||||
{
|
||||
clone->Vertices = Vertices;
|
||||
clone->BoundingBox = BoundingBox;
|
||||
}
|
||||
|
||||
if (cloneFlags & ECF_INDICES)
|
||||
{
|
||||
clone->Indices = Indices;
|
||||
}
|
||||
|
||||
clone->PrimitiveType = PrimitiveType;
|
||||
clone->Material = getMaterial();
|
||||
clone->MappingHint_Vertex = MappingHint_Vertex;
|
||||
clone->MappingHint_Index = MappingHint_Index;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
//! Returns type of the class implementing the IMeshBuffer for template specialization
|
||||
// Minor note: Some compilers (VS) allow directly specializing the virtual function,
|
||||
// but this will fail on other compilers (GCC). So using a helper function.
|
||||
EMESH_BUFFER_TYPE getTypeT() const;
|
||||
|
||||
u32 ChangedID_Vertex;
|
||||
u32 ChangedID_Index;
|
||||
|
||||
@ -311,6 +346,25 @@ namespace scene
|
||||
typedef CMeshBuffer<video::S3DVertex2TCoords> SMeshBufferLightMap;
|
||||
//! Meshbuffer with vertices having tangents stored, e.g. for normal mapping
|
||||
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 irr
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace video
|
||||
EMT_SPHERE_MAP,
|
||||
|
||||
//! A reflecting material with an optional non reflecting texture layer.
|
||||
/** The reflection map should be set as first texture. */
|
||||
/** The reflection map should be set as second texture. */
|
||||
EMT_REFLECTION_2_LAYER,
|
||||
|
||||
//! A transparent material.
|
||||
|
44
include/EMeshBufferTypes.h
Normal file
44
include/EMeshBufferTypes.h
Normal file
@ -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 (16 bit buffers)
|
||||
EMBT_STANDARD = MAKE_IRR_ID('s','t','a','n'),
|
||||
|
||||
//! SMeshBufferLightMap (16 bit buffers)
|
||||
EMBT_LIGHTMAP = MAKE_IRR_ID('l','i','g','h'),
|
||||
|
||||
//! SMeshBufferTangents (16 bit buffers)
|
||||
EMBT_TANGENTS = MAKE_IRR_ID('t','a','n','g'),
|
||||
|
||||
//! CDynamicMeshBuffer (16 or 32 bit buffers)
|
||||
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 @@ namespace irr
|
||||
namespace scene
|
||||
{
|
||||
class ICameraSceneNode;
|
||||
class IMeshBuffer;
|
||||
|
||||
//! A billboard scene node.
|
||||
/** A billboard is like a 3d sprite: A 2d element,
|
||||
@ -74,6 +75,17 @@ public:
|
||||
That is why the usual getBoundingBox will return a "safe" boundingbox which is guaranteed
|
||||
to contain the billboard. While this function can return the real one. */
|
||||
virtual const core::aabbox3d<f32>& getTransformedBillboardBoundingBox(const irr::scene::ICameraSceneNode* camera) = 0;
|
||||
|
||||
//! Get the amount of mesh buffers.
|
||||
/** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */
|
||||
virtual u32 getMeshBufferCount() const = 0;
|
||||
|
||||
//! Get pointer to a mesh buffer.
|
||||
/** NOTE: Positions and normals of this meshbuffers are re-calculated before rendering.
|
||||
So this is mainly useful to access/modify the uv-coordinates.
|
||||
\param nr: Zero based index of the mesh buffer.
|
||||
\return Pointer to the mesh buffer or 0 if there is no such mesh buffer. */
|
||||
virtual IMeshBuffer* getMeshBuffer(u32 nr) const = 0;
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
@ -24,15 +24,31 @@ namespace scene
|
||||
{
|
||||
//! Single buffer with 12 different vertices, normals are average of adjacent planes
|
||||
//! Order for outgoing (front-face) normals of planes would be: NEG_Z, POS_X, POS_Z, NEG_X, POS_Y, NEG_Y
|
||||
//! This was the only available type before Irrlicht 1.9, so it's still the default in some functions.
|
||||
//! It has the least vertices, but is pretty much unusable if you have dynamic light
|
||||
ECMT_1BUF_12VTX_NA,
|
||||
|
||||
//! One buffer per side, each with 4 vertices, normals are perpendicular to sides
|
||||
//! Note: You probably will have to scale down your texture uv's to avoid white lines at borders
|
||||
// as this mesh sets them to 0,1 values. We can't do that when creating the mesh as it
|
||||
// depends on texture resolution which we don't know at that point.
|
||||
ECMT_6BUF_4VTX_NP
|
||||
//! You can use this one if you need different texture on each cube side
|
||||
ECMT_6BUF_4VTX_NP,
|
||||
|
||||
//! Single buffer with 24 different vertices, normals are perpendicular to sides
|
||||
ECMT_1BUF_24VTX_NP,
|
||||
|
||||
//! not used, counts the number of enumerated types
|
||||
ECMT_COUNT
|
||||
};
|
||||
|
||||
//! Names for ECUBE_MESH_TYPE
|
||||
const c8* const CubeMeshTypeNames[ECMT_COUNT+1] =
|
||||
{
|
||||
"1BUF_12VTX_NA",
|
||||
"ECMT_6BUF_4VTX_NP",
|
||||
"1BUF_24VTX_NP",
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
//! Helper class for creating geometry on the fly.
|
||||
/** You can get an instance of this class through ISceneManager::getGeometryCreator() */
|
||||
class IGeometryCreator : public IReferenceCounted
|
||||
@ -44,6 +60,9 @@ public:
|
||||
\param size Dimensions of the cube.
|
||||
\param type One of ECUBE_MESH_TYPE. So you can chose between cubes with single material or independent materials per side.
|
||||
\return Generated mesh.
|
||||
Note: UV's go always from 0 to 1. Which can produce wrong colors at edges with texture filtering.
|
||||
Fixing UV's depends on texture-size (have to be moved half a pixel towards the inside, so 0.5f/texure_size as then the pixel center is exactly on the border)
|
||||
Easier solution is usually to set TextureWrapU and TextureWrapV to ETC_CLAMP_TO_EDGE in the Material.
|
||||
*/
|
||||
virtual IMesh* createCubeMesh(const core::vector3df& size=core::vector3df(5.f,5.f,5.f), ECUBE_MESH_TYPE type = ECMT_1BUF_12VTX_NA) const =0;
|
||||
|
||||
|
@ -74,7 +74,6 @@ public:
|
||||
//! Returns bits per pixel.
|
||||
u32 getBitsPerPixel() const
|
||||
{
|
||||
|
||||
return getBitsPerPixelFromFormat(Format);
|
||||
}
|
||||
|
||||
@ -359,6 +358,11 @@ public:
|
||||
/** NOTE: mipmaps are ignored */
|
||||
virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false) = 0;
|
||||
|
||||
//! Flips (mirrors) the image in one or two directions
|
||||
/** \param topBottom Flip around central x-axis (vertical flipping)
|
||||
\param leftRight Flip around central y-axis (typical mirror, horizontal flipping) */
|
||||
virtual void flip(bool topBottom, bool leftRight) = 0;
|
||||
|
||||
//! fills the surface with given color
|
||||
virtual void fill(const SColor &color) =0;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "SVertexIndex.h"
|
||||
#include "EHardwareBufferFlags.h"
|
||||
#include "EPrimitiveTypes.h"
|
||||
#include "EMeshBufferTypes.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -71,11 +72,17 @@ namespace scene
|
||||
virtual video::E_INDEX_TYPE getIndexType() const =0;
|
||||
|
||||
//! Get access to indices.
|
||||
/** \return Pointer to indices array. */
|
||||
/** Note: For historical reasons data pointer is of type u16*, but
|
||||
for an index type of EIT_32BIT the index data is using an u32 array
|
||||
and therefore needs a cast to u32*.
|
||||
\return Pointer to indices array. */
|
||||
virtual const u16* getIndices() const = 0;
|
||||
|
||||
//! Get access to indices.
|
||||
/** \return Pointer to indices array. */
|
||||
/** Note: For historical reasons data pointer is of type u16*, but
|
||||
for an index type of EIT_32BIT the index data is using an u32 array
|
||||
and therefore needs a cast to u32*.
|
||||
\return Pointer to indices array. */
|
||||
virtual u16* getIndices() = 0;
|
||||
|
||||
//! Get amount of indices in this meshbuffer.
|
||||
@ -176,6 +183,24 @@ 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;
|
||||
}
|
||||
|
||||
//! Bitflags with options for cloning
|
||||
enum ECloneFlags
|
||||
{
|
||||
ECF_VERTICES = 1, //! clone the vertices (or copy pointer for SSharedMeshBuffer)
|
||||
ECF_INDICES = 2 //! clone the indices
|
||||
};
|
||||
|
||||
//! Create a new object with a copy of the meshbuffer
|
||||
//\param cloneFlags A combination of ECloneFlags
|
||||
virtual IMeshBuffer* createClone(int cloneFlags=ECF_VERTICES|ECF_INDICES) const = 0;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "IReferenceCounted.h"
|
||||
#include "path.h"
|
||||
#include "IMeshTextureLoader.h"
|
||||
#include "SVertexIndex.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -29,7 +30,7 @@ class IMeshLoader : public virtual IReferenceCounted
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
IMeshLoader() : TextureLoader(0) {}
|
||||
IMeshLoader() : TextureLoader(0), PreferredIndexType(video::EIT_16BIT) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~IMeshLoader()
|
||||
@ -78,8 +79,30 @@ public:
|
||||
return TextureLoader;
|
||||
}
|
||||
|
||||
//! Give loader a hint if you would prefer 16 or 32 bit meshbuffers.
|
||||
/**
|
||||
Generally Irrlicht works with 16-bit meshbuffers so far.
|
||||
Rendering 32-bit meshbuffers works, other functions like
|
||||
mesh-writing and mesh manipulation might not work yet.
|
||||
NOTE: Most loaders will ignore this hint so far, but hopefully
|
||||
will care about it in the future.
|
||||
*/
|
||||
void setPreferredIndexType(irr::video::E_INDEX_TYPE typeHint)
|
||||
{
|
||||
PreferredIndexType = typeHint;
|
||||
}
|
||||
|
||||
//! Return current preference user has for the index-size of meshbuffers
|
||||
/** Note that this is _not_ necessarily the type used by the meshloader */
|
||||
irr::video::E_INDEX_TYPE getPreferredIndexType() const
|
||||
{
|
||||
return PreferredIndexType;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
IMeshTextureLoader* TextureLoader;
|
||||
irr::video::E_INDEX_TYPE PreferredIndexType;
|
||||
};
|
||||
|
||||
|
||||
|
@ -229,9 +229,7 @@ namespace scene
|
||||
u8 axis, const core::vector3df& offset) const=0;
|
||||
|
||||
//! Clones a static IMesh into a modifiable SMesh.
|
||||
/** All meshbuffers in the returned SMesh
|
||||
are of type SMeshBuffer or SMeshBufferLightMap.
|
||||
\param mesh Mesh to copy.
|
||||
/** \param mesh Mesh to copy.
|
||||
\return Cloned mesh. If you no longer need the
|
||||
cloned mesh, you should call SMesh::drop(). See
|
||||
IReferenceCounted::drop() for more information. */
|
||||
|
@ -453,13 +453,15 @@ namespace scene
|
||||
where the scene node will be placed.
|
||||
\param rotation: Initial rotation of the scene node.
|
||||
\param scale: Initial scale of the scene node.
|
||||
\param type: Type of cube-mesh to create. Check ECUBE_MESH_TYPE documentation for more info
|
||||
\return Pointer to the created test scene node. This
|
||||
pointer should not be dropped. See IReferenceCounted::drop()
|
||||
for more information. */
|
||||
virtual IMeshSceneNode* addCubeSceneNode(f32 size=10.0f, ISceneNode* parent=0, s32 id=-1,
|
||||
const core::vector3df& position = core::vector3df(0,0,0),
|
||||
const core::vector3df& rotation = core::vector3df(0,0,0),
|
||||
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0;
|
||||
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f),
|
||||
ECUBE_MESH_TYPE type=ECMT_1BUF_12VTX_NA) = 0;
|
||||
|
||||
//! Adds a sphere scene node of the given radius and detail
|
||||
/** \param radius: Radius of the sphere.
|
||||
|
@ -18,17 +18,27 @@ namespace scene
|
||||
class IVertexBuffer : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
//! Pointer to first element of vertex data
|
||||
virtual void* getData() =0;
|
||||
|
||||
virtual video::E_VERTEX_TYPE getType() const =0;
|
||||
virtual void setType(video::E_VERTEX_TYPE vertexType) =0;
|
||||
|
||||
//! Number of bytes per element
|
||||
virtual u32 stride() const =0;
|
||||
|
||||
//! Number of elements
|
||||
virtual u32 size() const =0;
|
||||
|
||||
//! Add vertex to end. Note that depending on vertex type this will be one of the types derived from video::S3DVertex.
|
||||
virtual void push_back(const video::S3DVertex &element) =0;
|
||||
virtual video::S3DVertex& operator [](const u32 index) const =0;
|
||||
virtual video::S3DVertex& getLast() =0;
|
||||
virtual void set_used(u32 usedNow) =0;
|
||||
virtual void reallocate(u32 new_size) =0;
|
||||
virtual u32 allocated_size() const =0;
|
||||
|
||||
//! Same as getData() - not sure why we got 2, should probably deprecate (and we don't always have video::S3DVertex*, so just confusing)
|
||||
virtual video::S3DVertex* pointer() =0;
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
|
@ -801,7 +801,7 @@ namespace video
|
||||
\param texture Texture to be drawn.
|
||||
\param destPos Upper left 2d destination position where the
|
||||
image will be drawn.
|
||||
\param sourceRect Source rectangle in the image.
|
||||
\param sourceRect Source rectangle in the texture (based on it's OriginalSize)
|
||||
\param clipRect Pointer to rectangle on the screen where the
|
||||
image is clipped to.
|
||||
If this pointer is NULL the image is not clipped.
|
||||
@ -823,7 +823,7 @@ namespace video
|
||||
\param texture Texture to be drawn.
|
||||
\param pos Upper left 2d destination position where the image
|
||||
will be drawn.
|
||||
\param sourceRects Source rectangles of the image.
|
||||
\param sourceRects Source rectangles of the texture (based on it's OriginalSize)
|
||||
\param indices List of indices which choose the actual
|
||||
rectangle used each time.
|
||||
\param kerningWidth Offset to Position on X
|
||||
@ -851,7 +851,7 @@ namespace video
|
||||
\param texture Texture to be drawn.
|
||||
\param positions Array of upper left 2d destinations where the
|
||||
images will be drawn.
|
||||
\param sourceRects Source rectangles of the image.
|
||||
\param sourceRects Source rectangles of the texture (based on it's OriginalSize)
|
||||
\param clipRect Pointer to rectangle on the screen where the
|
||||
images are clipped to.
|
||||
If this pointer is 0 then the image is not clipped.
|
||||
@ -871,7 +871,7 @@ namespace video
|
||||
/** Suggested and first implemented by zola.
|
||||
\param texture The texture to draw from
|
||||
\param destRect The rectangle to draw into
|
||||
\param sourceRect The rectangle denoting a part of the texture
|
||||
\param sourceRect The rectangle denoting a part of the texture (based on it's OriginalSize)
|
||||
\param clipRect Clips the destination rectangle (may be 0)
|
||||
\param colors Array of 4 colors denoting the color values of
|
||||
the corners of the destRect
|
||||
@ -1343,7 +1343,7 @@ namespace video
|
||||
E_MATERIAL_TYPE enum or a value which was returned by
|
||||
addMaterialRenderer().
|
||||
\param name: New name of the material renderer. */
|
||||
virtual void setMaterialRendererName(s32 idx, const c8* name) =0;
|
||||
virtual void setMaterialRendererName(u32 idx, const c8* name) =0;
|
||||
|
||||
//! Swap the material renderers used for certain id's
|
||||
/** Swap the IMaterialRenderers responsible for rendering specific
|
||||
|
@ -172,9 +172,16 @@ namespace scene
|
||||
}
|
||||
|
||||
//! append the vertices and indices to the current buffer
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE {}
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE
|
||||
{
|
||||
// can't do that as it doesn't own the vertex memory
|
||||
}
|
||||
|
||||
//! append the meshbuffer to the current buffer
|
||||
virtual void append(const IMeshBuffer* const other) IRR_OVERRIDE {}
|
||||
virtual void append(const IMeshBuffer* const other) IRR_OVERRIDE
|
||||
{
|
||||
// can't do that as it doesn't own the vertex memory
|
||||
}
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const IRR_OVERRIDE
|
||||
@ -226,6 +233,36 @@ 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;
|
||||
}
|
||||
|
||||
//! Create copy of the meshbuffer
|
||||
virtual IMeshBuffer* createClone(int cloneFlags) const IRR_OVERRIDE
|
||||
{
|
||||
SSharedMeshBuffer * clone = new SSharedMeshBuffer();
|
||||
|
||||
if (cloneFlags & ECF_VERTICES)
|
||||
{
|
||||
clone->Vertices = Vertices;
|
||||
clone->BoundingBox = BoundingBox;
|
||||
}
|
||||
|
||||
if (cloneFlags & ECF_INDICES)
|
||||
{
|
||||
clone->Indices = Indices;
|
||||
}
|
||||
|
||||
clone->Material = Material;
|
||||
clone->MappingHintVertex = MappingHintVertex;
|
||||
clone->MappingHintIndex = MappingHintIndex;
|
||||
clone->PrimitiveType = PrimitiveType;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
//! Material of this meshBuffer
|
||||
video::SMaterial Material;
|
||||
|
||||
|
@ -383,6 +383,41 @@ 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;
|
||||
}
|
||||
|
||||
//! Create copy of the meshbuffer
|
||||
virtual IMeshBuffer* createClone(int cloneFlags) const IRR_OVERRIDE
|
||||
{
|
||||
SSkinMeshBuffer* clone = new SSkinMeshBuffer(VertexType);
|
||||
|
||||
if (cloneFlags & ECF_VERTICES)
|
||||
{
|
||||
clone->Vertices_Tangents = Vertices_Tangents;
|
||||
clone->Vertices_2TCoords = Vertices_2TCoords;
|
||||
clone->Vertices_Standard = Vertices_Standard;
|
||||
|
||||
clone->BoundingBox = BoundingBox;
|
||||
clone->BoundingBoxNeedsRecalculated = BoundingBoxNeedsRecalculated;
|
||||
}
|
||||
|
||||
if (cloneFlags & ECF_INDICES)
|
||||
{
|
||||
clone->Indices = Indices;
|
||||
}
|
||||
|
||||
clone->Transformation = Transformation;
|
||||
clone->Material = getMaterial();
|
||||
clone->PrimitiveType = PrimitiveType;
|
||||
clone->MappingHint_Vertex = MappingHint_Vertex;
|
||||
clone->MappingHint_Index = MappingHint_Index;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
//! Call this after changing the positions of any vertex.
|
||||
void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; }
|
||||
|
||||
|
@ -234,9 +234,10 @@ public:
|
||||
//! Set (copy) data from given memory block
|
||||
/** \param newData data to set, must have newSize elements
|
||||
\param newSize Amount of elements in newData
|
||||
\param canShrink When true we reallocate the array even it can shrink.
|
||||
May reduce memory usage, but call is more whenever size changes.
|
||||
\param newDataIsSorted Info if you pass sorted/unsorted data
|
||||
\param canShrink Specifies whether the array is reallocated even if
|
||||
enough space is available. Setting this flag to false can speed up
|
||||
array usage, but may use more memory than required by the data.
|
||||
*/
|
||||
void set_data(const T* newData, u32 newSize, bool newDataIsSorted=false, bool canShrink=false)
|
||||
{
|
||||
@ -299,22 +300,27 @@ public:
|
||||
return *this;
|
||||
strategy = other.strategy;
|
||||
|
||||
// (TODO: we could probably avoid re-allocations of data when (allocated < other.allocated)
|
||||
|
||||
if (data)
|
||||
clear();
|
||||
|
||||
//if (allocated < other.allocated)
|
||||
if (other.allocated == 0)
|
||||
data = 0;
|
||||
else
|
||||
data = allocator.allocate(other.allocated); // new T[other.allocated];
|
||||
|
||||
used = other.used;
|
||||
free_when_destroyed = true;
|
||||
is_sorted = other.is_sorted;
|
||||
allocated = other.allocated;
|
||||
|
||||
for (u32 i=0; i<other.used; ++i)
|
||||
allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];
|
||||
if (other.allocated == 0)
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = allocator.allocate(other.allocated); // new T[other.allocated];
|
||||
|
||||
for (u32 i=0; i<other.used; ++i)
|
||||
allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -159,20 +159,20 @@ class line2d
|
||||
{
|
||||
// Uses the method given at:
|
||||
// http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
|
||||
const f32 commonDenominator = (f32)((l.end.Y - l.start.Y)*(end.X - start.X) -
|
||||
const f64 commonDenominator = (f64)((l.end.Y - l.start.Y)*(end.X - start.X) -
|
||||
(l.end.X - l.start.X)*(end.Y - start.Y));
|
||||
|
||||
const f32 numeratorA = (f32)((l.end.X - l.start.X)*(start.Y - l.start.Y) -
|
||||
const f64 numeratorA = (f64)((l.end.X - l.start.X)*(start.Y - l.start.Y) -
|
||||
(l.end.Y - l.start.Y)*(start.X -l.start.X));
|
||||
|
||||
const f32 numeratorB = (f32)((end.X - start.X)*(start.Y - l.start.Y) -
|
||||
const f64 numeratorB = (f64)((end.X - start.X)*(start.Y - l.start.Y) -
|
||||
(end.Y - start.Y)*(start.X -l.start.X));
|
||||
|
||||
if(equals(commonDenominator, 0.f))
|
||||
if(equals(commonDenominator, 0.0))
|
||||
{
|
||||
// The lines are either coincident or parallel
|
||||
// if both numerators are 0, the lines are coincident
|
||||
if(!ignoreCoincidentLines && equals(numeratorA, 0.f) && equals(numeratorB, 0.f))
|
||||
if(!ignoreCoincidentLines && equals(numeratorA, 0.0) && equals(numeratorB, 0.0))
|
||||
{
|
||||
// Try and find a common endpoint
|
||||
if(l.start == start || l.end == start)
|
||||
@ -235,14 +235,14 @@ class line2d
|
||||
|
||||
// Get the point of intersection on this line, checking that
|
||||
// it is within the line segment.
|
||||
const f32 uA = numeratorA / commonDenominator;
|
||||
const f64 uA = numeratorA / commonDenominator;
|
||||
if (checkOnlySegments)
|
||||
{
|
||||
if(uA < 0.f || uA > 1.f)
|
||||
if(uA < 0.0 || uA > 1.0)
|
||||
return false; // Outside the line segment
|
||||
|
||||
const f32 uB = numeratorB / commonDenominator;
|
||||
if(uB < 0.f || uB > 1.f)
|
||||
const f64 uB = numeratorB / commonDenominator;
|
||||
if(uB < 0.0 || uB > 1.0)
|
||||
return false; // Outside the line segment
|
||||
}
|
||||
|
||||
|
@ -1155,10 +1155,10 @@ namespace core
|
||||
template <class T>
|
||||
inline void CMatrix4<T>::rotateVect( vector3df& vect ) const
|
||||
{
|
||||
vector3df tmp = vect;
|
||||
vect.X = tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8];
|
||||
vect.Y = tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9];
|
||||
vect.Z = tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10];
|
||||
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
|
||||
vect.X = static_cast<f32>(tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8]);
|
||||
vect.Y = static_cast<f32>(tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9]);
|
||||
vect.Z = static_cast<f32>(tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10]);
|
||||
}
|
||||
|
||||
//! An alternate transform vector method, writing into a second vector
|
||||
@ -1182,24 +1182,24 @@ namespace core
|
||||
template <class T>
|
||||
inline void CMatrix4<T>::inverseRotateVect( vector3df& vect ) const
|
||||
{
|
||||
vector3df tmp = vect;
|
||||
vect.X = tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2];
|
||||
vect.Y = tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6];
|
||||
vect.Z = tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10];
|
||||
vector3d<T> tmp(static_cast<T>(vect.X), static_cast<T>(vect.Y), static_cast<T>(vect.Z));
|
||||
vect.X = static_cast<f32>(tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]);
|
||||
vect.Y = static_cast<f32>(tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]);
|
||||
vect.Z = static_cast<f32>(tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void CMatrix4<T>::transformVect( vector3df& vect) const
|
||||
{
|
||||
f32 vector[3];
|
||||
T vector[3];
|
||||
|
||||
vector[0] = vect.X*M[0] + vect.Y*M[4] + vect.Z*M[8] + M[12];
|
||||
vector[1] = vect.X*M[1] + vect.Y*M[5] + vect.Z*M[9] + M[13];
|
||||
vector[2] = vect.X*M[2] + vect.Y*M[6] + vect.Z*M[10] + M[14];
|
||||
|
||||
vect.X = vector[0];
|
||||
vect.Y = vector[1];
|
||||
vect.Z = vector[2];
|
||||
vect.X = static_cast<f32>(vector[0]);
|
||||
vect.Y = static_cast<f32>(vector[1]);
|
||||
vect.Z = static_cast<f32>(vector[2]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -54,8 +54,8 @@ namespace core
|
||||
|
||||
vector3d<T> operator/(const vector3d<T>& other) const { return vector3d<T>(X / other.X, Y / other.Y, Z / other.Z); }
|
||||
vector3d<T>& operator/=(const vector3d<T>& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; }
|
||||
vector3d<T> operator/(const T v) const { T i=(T)1.0/v; return vector3d<T>(X * i, Y * i, Z * i); }
|
||||
vector3d<T>& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; }
|
||||
vector3d<T> operator/(const T v) const { return vector3d<T>(X/v, Y/v, Z/v); }
|
||||
vector3d<T>& operator/=(const T v) { X/=v; Y/=v; Z/=v; return *this; }
|
||||
|
||||
T& operator [](u32 index)
|
||||
{
|
||||
|
Reference in New Issue
Block a user