OGRE  1.9.0
OgreOptimisedUtil.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __OptimisedUtil_H__
29#define __OptimisedUtil_H__
30
31#include "OgrePrerequisites.h"
32#include "OgreEdgeListBuilder.h"
33#include <cstddef>
34
35namespace Ogre {
36
48 {
49 private:
51 OptimisedUtil(const OptimisedUtil& rhs); /* do nothing, should not use */
53 OptimisedUtil& operator=(const OptimisedUtil& rhs); /* do not use */
54
55 protected:
58
61
62 public:
63 // Default constructor
65 // Destructor
66 virtual ~OptimisedUtil() {}
67
73 static OptimisedUtil* getImplementation(void) { return msImplementation; }
74
100 const float *srcPosPtr, float *destPosPtr,
101 const float *srcNormPtr, float *destNormPtr,
102 const float *blendWeightPtr, const unsigned char* blendIndexPtr,
103 const Matrix4* const* blendMatrices,
104 size_t srcPosStride, size_t destPosStride,
105 size_t srcNormStride, size_t destNormStride,
106 size_t blendWeightStride, size_t blendIndexStride,
107 size_t numWeightsPerVertex,
108 size_t numVertices) = 0;
109
125 Real t,
126 const float *srcPos1, const float *srcPos2,
127 float *dstPos,
128 size_t pos1VSize, size_t pos2VSize, size_t dstVSize,
129 size_t numVertices,
130 bool morphNormals) = 0;
131
142 const Matrix4& baseMatrix,
143 const Matrix4* srcMatrices,
144 Matrix4* dstMatrices,
145 size_t numMatrices) = 0;
146
159 const float *positions,
160 const EdgeData::Triangle *triangles,
161 Vector4 *faceNormals,
162 size_t numTriangles) = 0;
163
181 const Vector4& lightPos,
182 const Vector4* faceNormals,
183 char* lightFacings,
184 size_t numFaces) = 0;
185
200 virtual void extrudeVertices(
201 const Vector4& lightPos,
202 Real extrudeDist,
203 const float* srcPositions,
204 float* destPositions,
205 size_t numVertices) = 0;
206 };
207
212 template <class T>
213 static FORCEINLINE const T* rawOffsetPointer(const T* ptr, ptrdiff_t offset)
214 {
215 return (const T*)((const char*)(ptr) + offset);
216 }
217
218 template <class T>
219 static FORCEINLINE T* rawOffsetPointer(T* ptr, ptrdiff_t offset)
220 {
221 return (T*)((char*)(ptr) + offset);
222 }
223
228 template <class T>
229 static FORCEINLINE void advanceRawPointer(const T*& ptr, ptrdiff_t offset)
230 {
231 ptr = rawOffsetPointer(ptr, offset);
232 }
233
234 template <class T>
235 static FORCEINLINE void advanceRawPointer(T*& ptr, ptrdiff_t offset)
236 {
237 ptr = rawOffsetPointer(ptr, offset);
238 }
242}
243
244#endif // __OptimisedUtil_H__
#define _OgreExport
Definition: OgrePlatform.h:260
#define FORCEINLINE
Definition: OgrePlatform.h:102
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
Utility class for provides optimised functions.
virtual void softwareVertexMorph(Real t, const float *srcPos1, const float *srcPos2, float *dstPos, size_t pos1VSize, size_t pos2VSize, size_t dstVSize, size_t numVertices, bool morphNormals)=0
Performs a software vertex morph, of the kind used for morph animation although it can be used for ot...
virtual void concatenateAffineMatrices(const Matrix4 &baseMatrix, const Matrix4 *srcMatrices, Matrix4 *dstMatrices, size_t numMatrices)=0
Concatenate an affine matrix to an array of affine matrices.
static OptimisedUtil * _detectImplementation(void)
Detect best implementation based on run-time environment.
virtual void extrudeVertices(const Vector4 &lightPos, Real extrudeDist, const float *srcPositions, float *destPositions, size_t numVertices)=0
Extruding vertices by a fixed distance based on light position.
virtual void softwareVertexSkinning(const float *srcPosPtr, float *destPosPtr, const float *srcNormPtr, float *destNormPtr, const float *blendWeightPtr, const unsigned char *blendIndexPtr, const Matrix4 *const *blendMatrices, size_t srcPosStride, size_t destPosStride, size_t srcNormStride, size_t destNormStride, size_t blendWeightStride, size_t blendIndexStride, size_t numWeightsPerVertex, size_t numVertices)=0
Performs software vertex skinning.
static OptimisedUtil * getImplementation(void)
Gets the implementation of this class.
OptimisedUtil & operator=(const OptimisedUtil &rhs)
Privated operator=, to prevent misuse.
virtual void calculateFaceNormals(const float *positions, const EdgeData::Triangle *triangles, Vector4 *faceNormals, size_t numTriangles)=0
Calculate the face normals for the triangles based on position information.
virtual void calculateLightFacing(const Vector4 &lightPos, const Vector4 *faceNormals, char *lightFacings, size_t numFaces)=0
Calculate the light facing state of the triangle's face normals.
OptimisedUtil(const OptimisedUtil &rhs)
Privated copy constructor, to prevent misuse.
static OptimisedUtil * msImplementation
Store a pointer to the implementation.
4-dimensional homogeneous vector.
Definition: OgreVector4.h:46
static FORCEINLINE void advanceRawPointer(const T *&ptr, ptrdiff_t offset)
Advance the pointer with raw offset.
static FORCEINLINE const T * rawOffsetPointer(const T *ptr, ptrdiff_t offset)
Returns raw offseted of the given pointer.
float Real
Software floating point type.
Basic triangle structure.