SSE2: Prepare for CVector alignment

--HG--
branch : sse2
hg/feature/sse2
kaetemi 11 years ago
parent dbb966c8a5
commit 95fb48fbfc

@ -43,6 +43,7 @@ namespace NL3D
using NLMISC::CVector;
using NLMISC::CVectorPacked;
using NLMISC::CPlane;
using NLMISC::CMatrix;
class CMRMBuilder;
@ -405,12 +406,24 @@ public:
uint8 Weights[NL3D_MESH_MRM_SKINNED_MAX_MATRIX];
// Decompact it
inline void getPos (CVectorPacked &dest, float factor) const
{
dest.x = (float)X * factor;
dest.y = (float)Y * factor;
dest.z = (float)Z * factor;
}
inline void getPos (CVector &dest, float factor) const
{
dest.x = (float)X * factor;
dest.y = (float)Y * factor;
dest.z = (float)Z * factor;
}
inline void getNormal (CVectorPacked &dest) const
{
dest.x = (float)Nx * (1.f/NL3D_MESH_MRM_SKINNED_NORMAL_FACTOR);
dest.y = (float)Ny * (1.f/NL3D_MESH_MRM_SKINNED_NORMAL_FACTOR);
dest.z = (float)Nz * (1.f/NL3D_MESH_MRM_SKINNED_NORMAL_FACTOR);
}
inline void getNormal (CVector &dest) const
{
dest.x = (float)Nx * (1.f/NL3D_MESH_MRM_SKINNED_NORMAL_FACTOR);
@ -480,6 +493,10 @@ public:
}
// Decompact position
inline void getPos (CVectorPacked &dest, const CPackedVertex &src) const
{
src.getPos (dest, _DecompactScale);
}
inline void getPos (CVector &dest, const CPackedVertex &src) const
{
src.getPos (dest, _DecompactScale);

@ -164,6 +164,7 @@ private:
void addInstance(const CShapeInfo &si, const NLMISC::CMatrix &matrix, TVertexGrid &vertexGrid, TTriListGrid &triListGrid);
public:
// PRIVATE : unpack a packed tri
void unpackTri(const CPackedTri &src, NLMISC::CVectorPacked dest[3]) const;
void unpackTri(const CPackedTri &src, NLMISC::CVector dest[3]) const;
};
@ -197,6 +198,7 @@ private:
NLMISC::CVector _PackedLocalToWorld;
public:
// PRIVATE : unpack a packed tri
void unpackTri(const CPackedTri16 &src, NLMISC::CVectorPacked dest[3]) const;
void unpackTri(const CPackedTri16 &src, NLMISC::CVector dest[3]) const;
};

@ -30,15 +30,21 @@ namespace NL3D
using NLMISC::CVector;
using NLMISC::CVectorPacked;
using NLMISC::CUV;
/// A simple Vertex Pos/Normal/Uv
class CRawSkinVertex
{
public:
CVector Pos;
CVector Normal;
CUV UV;
#if USE_SSE2
CVectorPacked Pos;
CVectorPacked Normal;
#else
CVector Pos;
CVector Normal;
#endif
CUV UV;
};
/// Vertices influenced by 1 matrix only.

@ -790,8 +790,8 @@ public:
* A call to IDriver::activeVertexBuffer() will change this format to the format returned by IDriver::getVertexColorFormat().
* So, before each write of vertex color in the vertex buffer, the vertex color format must be checked with CVertexBuffer::getVertexColorFormat().
*/
NLMISC::CVector* getVertexCoordPointer(uint idx=0);
NLMISC::CVector* getNormalCoordPointer(uint idx=0);
NLMISC::CVectorPacked* getVertexCoordPointer(uint idx=0);
NLMISC::CVectorPacked* getNormalCoordPointer(uint idx=0);
NLMISC::CUV* getTexCoordPointer(uint idx=0, uint8 stage=0);
void* getColorPointer(uint idx=0);
void* getSpecularPointer(uint idx=0);
@ -854,8 +854,8 @@ public:
* A call to IDriver::activeVertexBuffer() will change this format to the format returned by IDriver::getVertexColorFormat().
* So, before each write of vertex color in the vertex buffer, the vertex color format must be checked with CVertexBuffer::getVertexColorFormat().
*/
const NLMISC::CVector* getVertexCoordPointer(uint idx=0) const;
const NLMISC::CVector* getNormalCoordPointer(uint idx=0) const;
const NLMISC::CVectorPacked* getVertexCoordPointer(uint idx=0) const;
const NLMISC::CVectorPacked* getNormalCoordPointer(uint idx=0) const;
const NLMISC::CUV* getTexCoordPointer(uint idx=0, uint8 stage=0) const;
const void* getColorPointer(uint idx=0) const;
const void* getSpecularPointer(uint idx=0) const;

@ -141,6 +141,43 @@ public: // Methods.
friend CVector operator*(float f, const CVector &v0);
};
class CVectorPacked
{
public: // Attributes.
float x,y,z;
public:
/// @name Object.
//@{
/// Constructor which does nothing.
CVectorPacked() { }
/// Constructor .
CVectorPacked(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
/// Copy Constructor.
CVectorPacked(const CVector &v) : x(v.x), y(v.y), z(v.z) {}
//@}
void set(float _x, float _y, float _z)
{
x = _x;
y = _y;
z = _z;
}
CVectorPacked &operator += (const CVector &v)
{
x += v.x;
y += v.y;
z += v.z;
return *this;
}
operator CVector () const
{
return CVector(x, y, z);
}
};
// blend (faster version than the generic version found in algo.h)
inline CVector blend(const CVector &v0, const CVector &v1, float lambda)
{

@ -120,10 +120,10 @@ void CCloud::generate (CNoise3d &noise)
{
CVertexBufferReadWrite vba;
rVB.lock (vba);
CVector *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)_NbW*_Width,0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)_NbW*_Width,(float)_NbH*_Height,0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)_NbW*_Width,0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)_NbW*_Width,(float)_NbH*_Height,0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(0.0f, (float)_NbH*_Height,0.0f);
_CloudScape->_MatClear.setColor (CRGBA(0,0,0,0));
}
@ -197,10 +197,10 @@ void CCloud::light ()
{
CVertexBufferReadWrite vba;
rVB.lock (vba);
CVector *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector((float)0.0f, (float)0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)1.f, (float)0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)1.f, (float)1.f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector((float)0.0f, (float)0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)1.f, (float)0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)1.f, (float)1.f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)0.0f, (float)1.f, 0.0f);
}
@ -340,10 +340,10 @@ void CCloud::reset (NL3D::CCamera *pViewer)
CVertexBufferReadWrite vba;
rVB.lock (vba);
uint32 nVSize = rVB.getVertexSize ();
CVector *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(5.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(5.0f, 5.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(5.0f, 0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(5.0f, 5.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(0.0f, 5.0f, 0.0f);
_CloudScape->_MatClear.setColor (CRGBA(0,0,0,0));
}
@ -469,7 +469,7 @@ void CCloud::dispXYZ (CMaterial *pMat)
float oneOverNbWNbH = 1.0f / (_NbW*_NbH);
CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
uint32 nVSize = rVB.getVertexSize ();
CVector *pVertices;
CVectorPacked *pVertices;
CUV *pUV;
_Driver->activeVertexBuffer (rVB);
@ -487,9 +487,9 @@ void CCloud::dispXYZ (CMaterial *pMat)
rVB.lock (vba);
pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector(_Pos.x, _Pos.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(_Pos.x+_Size.x, _Pos.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(_Pos.x+_Size.x, _Pos.y+_Size.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(_Pos.x, _Pos.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(_Pos.x+_Size.x, _Pos.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(_Pos.x+_Size.x, _Pos.y+_Size.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(_Pos.x, _Pos.y+_Size.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH);
pUV = vba.getTexCoordPointer (0, 0);
@ -512,10 +512,10 @@ void CCloud::dispXYZ (CMaterial *pMat)
{
CVertexBufferReadWrite vba;
rVB.lock (vba);
CVector *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector((float)0.25f, 0, (float)0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)0.75f, 0, (float)0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)0.75f, 0, (float)0.75f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector((float)0.25f, 0, (float)0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)0.75f, 0, (float)0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)0.75f, 0, (float)0.75f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)0.25f, 0, (float)0.75f);
}
}
@ -664,10 +664,10 @@ void CCloud::genBill (CCamera *pCam, uint32 nBillSize)
CVertexBufferReadWrite vba;
rVB.lock (vba);
{
CVector *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(1.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(1.0f, 0.0f, 1.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer (0);
*pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(1.0f, 0.0f, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(1.0f, 0.0f, 1.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector(0.0f, 0.0f, 1.0f);
}
}
@ -782,10 +782,10 @@ void CCloud::dispBill (CCamera *pCam)
rVB.lock (vba);
uint32 nVSize = rVB.getVertexSize ();
CVector *pVertices = vba.getVertexCoordPointer (0);
*pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer (0);
*pVertices = qc.V0; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V3;
CUV *pUV = vba.getTexCoordPointer (0, 0);

@ -163,14 +163,14 @@ void CMeshMorpher::update (std::vector<CAnimatedMorph> *pBSFactor)
if (_VBDst->getVertexFormat() & CVertexBuffer::PositionFlag)
if (rBS.deltaPos.size() > 0)
{
CVector *pV = dstvba.getVertexCoordPointer (vp);
CVectorPacked *pV = dstvba.getVertexCoordPointer (vp);
*pV += rBS.deltaPos[j] * rFactor;
}
if (_VBDst->getVertexFormat() & CVertexBuffer::NormalFlag)
if (rBS.deltaNorm.size() > 0)
{
CVector *pV = dstvba.getNormalCoordPointer (vp);
CVectorPacked *pV = dstvba.getNormalCoordPointer (vp);
*pV += rBS.deltaNorm[j] * rFactor;
}
@ -264,13 +264,13 @@ void CMeshMorpher::updateSkinned (std::vector<CAnimatedMorph> *pBSFactor)
pDst[j+i*VBVertexSize] = pOri[j+i*VBVertexSize];
if (_Vertices != NULL)
_Vertices->operator[](i) = ((CVector*)(pOri+i*VBVertexSize))[0];
_Vertices->operator[](i) = ((CVectorPacked*)(pOri+i*VBVertexSize))[0];
if (_Normals != NULL)
_Normals->operator[](i) = ((CVector*)(pOri+i*VBVertexSize))[1];
_Normals->operator[](i) = ((CVectorPacked*)(pOri+i*VBVertexSize))[1];
if (_TgSpace != NULL)
(*_TgSpace)[i] = * (CVector*)(pOri + i * VBVertexSize + tgSpaceOff);
(*_TgSpace)[i] = * (CVectorPacked*)(pOri + i * VBVertexSize + tgSpaceOff);
_Flags[i] = OriginalVBDst;
}
@ -388,8 +388,8 @@ void CMeshMorpher::updateRawSkin (CVertexBuffer *vbOri,
{
if(*vRemap)
{
(*vRemap)->Pos= *(CVector*)(pOri);
(*vRemap)->Normal= *(CVector*)(pOri + NL3D_RAWSKIN_NORMAL_OFF);
(*vRemap)->Pos= *(CVectorPacked*)(pOri);
(*vRemap)->Normal= *(CVectorPacked*)(pOri + NL3D_RAWSKIN_NORMAL_OFF);
(*vRemap)->UV= *(CUV*)(pOri + NL3D_RAWSKIN_UV_OFF);
}
pOri+= NL3D_RAWSKIN_VERTEX_SIZE;
@ -420,9 +420,9 @@ void CMeshMorpher::updateRawSkin (CVertexBuffer *vbOri,
// If exist in this Lod RawSkin, apply
if(rsVert)
{
if(hasPos)
if(hasPos) // FIXME_SSE2: +=
rsVert->Pos+= rBS.deltaPos[j] * rFactor;
if(hasNorm)
if(hasNorm) // FIXME_SSE2: +=
rsVert->Normal+= rBS.deltaNorm[j] * rFactor;
if(hasUV)
rsVert->UV+= rBS.deltaUV[j] * rFactor;

@ -78,14 +78,18 @@ static void applyArraySkinNormalT(uint numMatrixes, uint32 *infPtr, CMesh::CSkin
CVector *srcVertex= srcVertexPtr + index;
CVector *srcNormal= srcNormalPtr + index;
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVector tempVertex;
CVector tempNormal;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, tempVertex);
*dstVertex = tempVertex;
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, tempNormal);
*dstNormal = tempNormal;
}
break;
@ -99,16 +103,20 @@ static void applyArraySkinNormalT(uint numMatrixes, uint32 *infPtr, CMesh::CSkin
CVector *srcVertex= srcVertexPtr + index;
CVector *srcNormal= srcNormalPtr + index;
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVector tempVertex;
CVector tempNormal;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], tempVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], tempVertex);
*dstVertex = tempVertex;
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], tempVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], tempVertex);
*dstNormal = tempNormal;
}
break;
@ -122,18 +130,22 @@ static void applyArraySkinNormalT(uint numMatrixes, uint32 *infPtr, CMesh::CSkin
CVector *srcVertex= srcVertexPtr + index;
CVector *srcNormal= srcNormalPtr + index;
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVector tempVertex;
CVector tempNormal;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], tempVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], tempVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], tempVertex);
*dstVertex = tempVertex;
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], tempNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], tempNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], tempNormal);
*dstNormal = tempNormal;
}
break;
@ -147,20 +159,24 @@ static void applyArraySkinNormalT(uint numMatrixes, uint32 *infPtr, CMesh::CSkin
CVector *srcVertex= srcVertexPtr + index;
CVector *srcNormal= srcNormalPtr + index;
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVector tempVertex;
CVector tempNormal;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddPoint( *srcVertex, srcSkin->Weights[3], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], tempVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], tempVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], tempVertex);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddPoint( *srcVertex, srcSkin->Weights[3], tempVertex);
*dstVertex = tempVertex;
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddVector( *srcNormal, srcSkin->Weights[3], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], tempNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], tempNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], tempNormal);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddVector( *srcNormal, srcSkin->Weights[3], tempNormal);
*dstNormal = tempNormal;
}
break;
@ -220,18 +236,24 @@ static void applyArraySkinTangentSpaceT(uint numMatrixes, uint32 *infPtr, CMesh:
CVector *srcTgSpace= tgSpacePtr + index;
//
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVector *dstTgSpace= (CVector*)(dstVertexVB + tgSpaceOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVectorPacked *dstTgSpace= (CVectorPacked*)(dstVertexVB + tgSpaceOff);
CVector tempVertex;
CVector tempNormal;
CVector tempTgSpace;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, tempVertex);
*dstVertex = tempVertex;
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, tempNormal);
*dstNormal = tempNormal;
// Tg space
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, tempTgSpace);
*dstTgSpace = tempTgSpace;
}
break;
@ -248,19 +270,25 @@ static void applyArraySkinTangentSpaceT(uint numMatrixes, uint32 *infPtr, CMesh:
CVector *srcTgSpace= tgSpacePtr + index;
//
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVector *dstTgSpace= (CVector*)(dstVertexVB + tgSpaceOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVectorPacked *dstTgSpace= (CVectorPacked*)(dstVertexVB + tgSpaceOff);
CVector tempVertex;
CVector tempNormal;
CVector tempTgSpace;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], tempVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], tempVertex);
*dstVertex = tempVertex;
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], tempNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], tempNormal);
*dstNormal = tempNormal;
// Tg space
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, srcSkin->Weights[0], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcTgSpace, srcSkin->Weights[1], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, srcSkin->Weights[0], tempTgSpace);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcTgSpace, srcSkin->Weights[1], tempTgSpace);
*dstTgSpace = tempTgSpace;
}
break;
@ -276,22 +304,28 @@ static void applyArraySkinTangentSpaceT(uint numMatrixes, uint32 *infPtr, CMesh:
CVector *srcTgSpace= tgSpacePtr + index;
//
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVector *dstTgSpace= (CVector*)(dstVertexVB + tgSpaceOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVectorPacked *dstTgSpace= (CVectorPacked*)(dstVertexVB + tgSpaceOff);
CVector tempVertex;
CVector tempNormal;
CVector tempTgSpace;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], tempVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], tempVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], tempVertex);
*dstVertex = tempVertex;
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], tempNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], tempNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], tempNormal);
*dstNormal = tempNormal;
// Tg space
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, srcSkin->Weights[0], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcTgSpace, srcSkin->Weights[1], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcTgSpace, srcSkin->Weights[2], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, srcSkin->Weights[0], tempTgSpace);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcTgSpace, srcSkin->Weights[1], tempTgSpace);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcTgSpace, srcSkin->Weights[2], tempTgSpace);
*dstTgSpace = tempTgSpace;
}
break;
@ -307,25 +341,33 @@ static void applyArraySkinTangentSpaceT(uint numMatrixes, uint32 *infPtr, CMesh:
CVector *srcTgSpace= tgSpacePtr + index;
//
uint8 *dstVertexVB= destVertexPtr + index * vertexSize;
CVector *dstVertex= (CVector*)(dstVertexVB);
CVector *dstNormal= (CVector*)(dstVertexVB + normalOff);
CVector *dstTgSpace= (CVector*)(dstVertexVB + tgSpaceOff);
CVectorPacked *dstVertex= (CVectorPacked*)(dstVertexVB);
CVectorPacked *dstNormal= (CVectorPacked*)(dstVertexVB + normalOff);
CVectorPacked *dstTgSpace= (CVectorPacked*)(dstVertexVB + tgSpaceOff);
CVector tempVertex;
CVector tempNormal;
CVector tempTgSpace;
// Vertex.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddPoint( *srcVertex, srcSkin->Weights[3], *dstVertex);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin->Weights[0], tempVertex);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin->Weights[1], tempVertex);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin->Weights[2], tempVertex);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddPoint( *srcVertex, srcSkin->Weights[3], tempVertex);
// Normal.
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddVector( *srcNormal, srcSkin->Weights[3], *dstNormal);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcNormal, srcSkin->Weights[0], tempNormal);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcNormal, srcSkin->Weights[1], tempNormal);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcNormal, srcSkin->Weights[2], tempNormal);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddVector( *srcNormal, srcSkin->Weights[3], tempNormal);
// Tg space
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, srcSkin->Weights[0], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcTgSpace, srcSkin->Weights[1], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcTgSpace, srcSkin->Weights[2], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddVector( *srcTgSpace, srcSkin->Weights[3], *dstTgSpace);
boneMat3x4[ srcSkin->MatrixId[0] ].mulSetVector( *srcTgSpace, srcSkin->Weights[0], tempTgSpace);
boneMat3x4[ srcSkin->MatrixId[1] ].mulAddVector( *srcTgSpace, srcSkin->Weights[1], tempTgSpace);
boneMat3x4[ srcSkin->MatrixId[2] ].mulAddVector( *srcTgSpace, srcSkin->Weights[2], tempTgSpace);
boneMat3x4[ srcSkin->MatrixId[3] ].mulAddVector( *srcTgSpace, srcSkin->Weights[3], tempTgSpace);
*dstVertex = tempVertex;
*dstNormal = tempNormal;
*dstTgSpace = tempTgSpace;
}
break;
@ -530,16 +572,19 @@ void CMeshMRMGeom::applyArrayRawSkinNormal1(CRawVertexNormalSkin1 *src, uint8 *
#ifndef NL3D_RAWSKIN_ASM
// for all InfluencedVertices only.
CVector tmp;
for(;nBlockInf>0;nBlockInf--, src++, destVertexPtr+=NL3D_RAWSKIN_VERTEX_SIZE)
{
CVector *dstVertex= (CVector*)(destVertexPtr);
CVector *dstNormal= (CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF);
CVectorPacked *dstVertex= (CVectorPacked*)(destVertexPtr);
CVectorPacked *dstNormal= (CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF);
// For 1 matrix, can write directly to AGP (if destVertexPtr is AGP...)
// Vertex.
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex.Pos, *(CVector*)(destVertexPtr) );
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex.Pos, tmp );
*(CVectorPacked*)(destVertexPtr) = tmp;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Vertex.Normal, *(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF) );
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Vertex.Normal, tmp );
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF) = tmp;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->Vertex.UV;
}
@ -717,11 +762,11 @@ void CMeshMRMGeom::applyArrayRawSkinNormal2(CRawVertexNormalSkin2 *src, uint8 *
// Vertex.
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex.Pos, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddPoint( src->Vertex.Pos, src->Weights[1], tmpVert);
*(CVector*)(destVertexPtr)= tmpVert;
*(CVectorPacked*)(destVertexPtr)= tmpVert;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Vertex.Normal, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddVector( src->Vertex.Normal, src->Weights[1], tmpVert);
*(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->Vertex.UV;
}
@ -1021,12 +1066,12 @@ void CMeshMRMGeom::applyArrayRawSkinNormal3(CRawVertexNormalSkin3 *src, uint8 *
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex.Pos, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddPoint( src->Vertex.Pos, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddPoint( src->Vertex.Pos, src->Weights[2], tmpVert);
*(CVector*)(destVertexPtr)= tmpVert;
*(CVectorPacked*)(destVertexPtr)= tmpVert;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Vertex.Normal, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddVector( src->Vertex.Normal, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddVector( src->Vertex.Normal, src->Weights[2], tmpVert);
*(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->Vertex.UV;
}
@ -1414,13 +1459,13 @@ void CMeshMRMGeom::applyArrayRawSkinNormal4(CRawVertexNormalSkin4 *src, uint8 *
boneMat3x4[ src->MatrixId[1] ].mulAddPoint( src->Vertex.Pos, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddPoint( src->Vertex.Pos, src->Weights[2], tmpVert);
boneMat3x4[ src->MatrixId[3] ].mulAddPoint( src->Vertex.Pos, src->Weights[3], tmpVert);
*(CVector*)(destVertexPtr)= tmpVert;
*(CVectorPacked*)(destVertexPtr)= tmpVert;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Vertex.Normal, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddVector( src->Vertex.Normal, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddVector( src->Vertex.Normal, src->Weights[2], tmpVert);
boneMat3x4[ src->MatrixId[3] ].mulAddVector( src->Vertex.Normal, src->Weights[3], tmpVert);
*(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->Vertex.UV;
}

@ -79,16 +79,19 @@ void CMeshMRMSkinnedGeom::applyArrayRawSkinNormal1(CRawVertexNormalSkinned1 *sr
#ifndef NL3D_RAWSKIN_ASM
// for all InfluencedVertices only.
CVector tmp;
for(;nBlockInf>0;nBlockInf--, src++, destVertexPtr+=NL3D_RAWSKIN_VERTEX_SIZE)
{
CVector *dstVertex= (CVector*)(destVertexPtr);
CVector *dstNormal= (CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF);
CVectorPacked *dstVertex= (CVectorPacked*)(destVertexPtr);
CVectorPacked *dstNormal= (CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF);
// For 1 matrix, can write directly to AGP (if destVertexPtr is AGP...)
// Vertex.
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex, *(CVector*)(destVertexPtr) );
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex, tmp );
*(CVectorPacked*)(destVertexPtr) = tmp;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Normal, *(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF) );
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Normal, tmp );
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF) = tmp;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->UV;
}
@ -266,11 +269,11 @@ void CMeshMRMSkinnedGeom::applyArrayRawSkinNormal2(CRawVertexNormalSkinned2 *sr
// Vertex.
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddPoint( src->Vertex, src->Weights[1], tmpVert);
*(CVector*)(destVertexPtr)= tmpVert;
*(CVectorPacked*)(destVertexPtr)= tmpVert;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Normal, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddVector( src->Normal, src->Weights[1], tmpVert);
*(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->UV;
}
@ -570,12 +573,12 @@ void CMeshMRMSkinnedGeom::applyArrayRawSkinNormal3(CRawVertexNormalSkinned3 *sr
boneMat3x4[ src->MatrixId[0] ].mulSetPoint( src->Vertex, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddPoint( src->Vertex, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddPoint( src->Vertex, src->Weights[2], tmpVert);
*(CVector*)(destVertexPtr)= tmpVert;
*(CVectorPacked*)(destVertexPtr)= tmpVert;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Normal, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddVector( src->Normal, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddVector( src->Normal, src->Weights[2], tmpVert);
*(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->UV;
}
@ -963,13 +966,13 @@ void CMeshMRMSkinnedGeom::applyArrayRawSkinNormal4(CRawVertexNormalSkinned4 *sr
boneMat3x4[ src->MatrixId[1] ].mulAddPoint( src->Vertex, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddPoint( src->Vertex, src->Weights[2], tmpVert);
boneMat3x4[ src->MatrixId[3] ].mulAddPoint( src->Vertex, src->Weights[3], tmpVert);
*(CVector*)(destVertexPtr)= tmpVert;
*(CVectorPacked*)(destVertexPtr)= tmpVert;
// Normal.
boneMat3x4[ src->MatrixId[0] ].mulSetVector( src->Normal, src->Weights[0], tmpVert);
boneMat3x4[ src->MatrixId[1] ].mulAddVector( src->Normal, src->Weights[1], tmpVert);
boneMat3x4[ src->MatrixId[2] ].mulAddVector( src->Normal, src->Weights[2], tmpVert);
boneMat3x4[ src->MatrixId[3] ].mulAddVector( src->Normal, src->Weights[3], tmpVert);
*(CVector*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
*(CVectorPacked*)(destVertexPtr + NL3D_RAWSKIN_NORMAL_OFF)= tmpVert;
// UV copy.
*(CUV*)(destVertexPtr + NL3D_RAWSKIN_UV_OFF)= src->UV;
}

@ -151,14 +151,14 @@ void CNoise3d::render2passes (CQuadUV &qc, float wpos, float alpha)
_VertexBuffer.lock (vba);
uint32 nVSize = _VertexBuffer.getVertexSize ();
CVector *pVertices = vba.getVertexCoordPointer(_NbVertices);
*pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V3; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer(_NbVertices);
*pVertices = qc.V0; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V3; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V0; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V3;
CUV *pUV = vba.getTexCoordPointer (_NbVertices, 0);
@ -232,10 +232,10 @@ void CNoise3d::render (CQuadUV &qc, float wpos, float intensity)
CVertexBufferReadWrite vba;
_VertexBuffer.lock (vba);
CVector *pVertices = vba.getVertexCoordPointer(_NbVertices);
*pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
CVectorPacked *pVertices = vba.getVertexCoordPointer(_NbVertices);
*pVertices = qc.V0; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V1; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V2; pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = qc.V3;
CUV *pUV = vba.getTexCoordPointer (_NbVertices, 0);
@ -281,7 +281,7 @@ void CNoise3d::renderGrid (uint32 nbw, uint32 nbh, uint32 w, uint32 h,
uint32 i, j, nSlice1, nSlice2;
float wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
CVector *pVertices;
CVectorPacked *pVertices;
CUV *pUV0, *pUV1;
uint8 *pColA, nAlphaPos;
uint32 nVSize = _VertexBuffer.getVertexSize ();
@ -319,10 +319,10 @@ void CNoise3d::renderGrid (uint32 nbw, uint32 nbh, uint32 w, uint32 h,
// If wpos is just on slice1 alpha must be one
nAlphaPos = (uint8)( 255*(1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth))) );
*pVertices = CVector((float)i*w, (float)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)j*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)j*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)(j+1)*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
pUV0->U = UStart+_OffS[nSlice1].U; pUV0->V = VStart+_OffS[nSlice1].V; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
pUV0->U = dU+_OffS[nSlice1].U; pUV0->V = VStart+_OffS[nSlice1].V; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
@ -350,7 +350,7 @@ void CNoise3d::renderGrid2passes (uint32 nbw, uint32 nbh, uint32 w, uint32 h,
{
uint32 i, j, nSlice1, nSlice2;
float wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
CVector *pVertices;
CVectorPacked *pVertices;
CUV *pUV0;
uint8 *pColA, nFinalAlpha;
uint32 nVSize = _VertexBuffer.getVertexSize ();
@ -387,14 +387,14 @@ void CNoise3d::renderGrid2passes (uint32 nbw, uint32 nbh, uint32 w, uint32 h,
// If wpos is just on slice1 alpha must be one
float alphaPos = 1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth));
*pVertices = CVector((float)i*w, (float)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)j*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)j*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)(j+1)*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)j*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)j*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
*pVertices = CVector((float)i*w, (float)(j+1)*h, 0.0f); pVertices = (CVectorPacked*)( ((uint8*)pVertices) + nVSize );
pUV0->U = UStart+_OffS[nSlice1].U; pUV0->V = VStart+_OffS[nSlice1].V; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
pUV0->U = dU+_OffS[nSlice1].U; pUV0->V = VStart+_OffS[nSlice1].V; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );

@ -576,6 +576,22 @@ void CPackedZone32::unpackTri(const CPackedTri &src, CVector dest[3]) const
}
// ***************************************************************************************
void CPackedZone32::unpackTri(const CPackedTri &src, CVectorPacked dest[3]) const
{
// TODO: add 'multiply-add' operator
dest[0].set(Verts[src.V0].X * _PackedLocalToWorld.x + _Origin.x,
Verts[src.V0].Y * _PackedLocalToWorld.y + _Origin.y,
Verts[src.V0].Z * _PackedLocalToWorld.z + _Origin.z);
dest[1].set(Verts[src.V1].X * _PackedLocalToWorld.x + _Origin.x,
Verts[src.V1].Y * _PackedLocalToWorld.y + _Origin.y,
Verts[src.V1].Z * _PackedLocalToWorld.z + _Origin.z);
dest[2].set(Verts[src.V2].X * _PackedLocalToWorld.x + _Origin.x,
Verts[src.V2].Y * _PackedLocalToWorld.y + _Origin.y,
Verts[src.V2].Z * _PackedLocalToWorld.z + _Origin.z);
}
uint32 CPackedZone32::UndefIndex = 0xffffffff;
// ***************************************************************************************
@ -973,8 +989,8 @@ void CPackedZone32::render(CVertexBuffer &vb, IDriver &drv, CMaterial &material,
CVertexBufferReadWrite vba;
vb.setNumVertices(batchSize * 3);
vb.lock(vba);
CVector *dest = vba.getVertexCoordPointer(0);
const CVector *endDest = dest + batchSize * 3;
CVectorPacked *dest = vba.getVertexCoordPointer(0);
const CVectorPacked *endDest = dest + batchSize * 3;
for(sint y = 0; y < (sint) silhouette.size(); ++y)
{
sint gridY = y + minY;
@ -1196,8 +1212,8 @@ void CPackedZone16::render(CVertexBuffer &vb, IDriver &drv, CMaterial &material,
CVertexBufferReadWrite vba;
vb.setNumVertices(batchSize * 3);
vb.lock(vba);
CVector *dest = vba.getVertexCoordPointer(0);
const CVector *endDest = dest + batchSize * 3;
CVectorPacked *dest = vba.getVertexCoordPointer(0);
const CVectorPacked *endDest = dest + batchSize * 3;
for(sint y = 0; y < (sint) silhouette.size(); ++y)
{
sint gridY = y + minY;
@ -1254,6 +1270,23 @@ void CPackedZone16::render(CVertexBuffer &vb, IDriver &drv, CMaterial &material,
// ***************************************************************************************
void CPackedZone16::unpackTri(const CPackedTri16 &src, CVectorPacked dest[3]) const
{
// yes this is ugly code duplication of CPackedZone16::unpackTri but this code is temporary anyway...
// TODO: add 'multiply-add' operator
dest[0].set(Verts[src.V0].X * _PackedLocalToWorld.x + _Origin.x,
Verts[src.V0].Y * _PackedLocalToWorld.y + _Origin.y,
Verts[src.V0].Z * _PackedLocalToWorld.z + _Origin.z);
dest[1].set(Verts[src.V1].X * _PackedLocalToWorld.x + _Origin.x,
Verts[src.V1].Y * _PackedLocalToWorld.y + _Origin.y,
Verts[src.V1].Z * _PackedLocalToWorld.z + _Origin.z);
dest[2].set(Verts[src.V2].X * _PackedLocalToWorld.x + _Origin.x,
Verts[src.V2].Y * _PackedLocalToWorld.y + _Origin.y,
Verts[src.V2].Z * _PackedLocalToWorld.z + _Origin.z);
}
// ***************************************************************************************
void CPackedZone16::unpackTri(const CPackedTri16 &src, CVector dest[3]) const
{

@ -128,15 +128,15 @@ void CVegetableShape::build(CVegetableShapeBuild &vbuild)
for(i=0;i<nbVerts;i++)
{
// Position.
const CVector *srcPos= vba.getVertexCoordPointer(i);
CVector *dstPos= vbaOut.getVertexCoordPointer(i);
const CVectorPacked *srcPos= vba.getVertexCoordPointer(i);
CVectorPacked *dstPos= vbaOut.getVertexCoordPointer(i);
*dstPos= *srcPos;
// Normal
if(Lighted)
{
const CVector *srcNormal= vba.getNormalCoordPointer(i);
CVector *dstNormal= vbaOut.getNormalCoordPointer(i);
const CVectorPacked *srcNormal= vba.getNormalCoordPointer(i);
CVectorPacked *dstNormal= vbaOut.getNormalCoordPointer(i);
*dstNormal= *srcNormal;
}

@ -1155,19 +1155,19 @@ IVBDrvInfos::~IVBDrvInfos()
// CVertexBufferReadWrite
// --------------------------------------------------
NLMISC::CVector* CVertexBufferReadWrite::getVertexCoordPointer(uint idx)
NLMISC::CVectorPacked* CVertexBufferReadWrite::getVertexCoordPointer(uint idx)
{
nlassert (_Parent->checkLockedBuffer());
uint8* ptr;
ptr=_Parent->_LockedBuffer;
ptr+=(idx*_Parent->_VertexSize);
return((NLMISC::CVector*)ptr);
return((NLMISC::CVectorPacked*)ptr);
}
// --------------------------------------------------
NLMISC::CVector* CVertexBufferReadWrite::getNormalCoordPointer(uint idx)
NLMISC::CVectorPacked* CVertexBufferReadWrite::getNormalCoordPointer(uint idx)
{
nlassert (_Parent->checkLockedBuffer());
uint8* ptr;
@ -1179,7 +1179,7 @@ NLMISC::CVector* CVertexBufferReadWrite::getNormalCoordPointer(uint idx)
ptr=_Parent->_LockedBuffer;
ptr+=_Parent->_Offset[CVertexBuffer::Normal];
ptr+=idx*_Parent->_VertexSize;
return((NLMISC::CVector*)ptr);
return((NLMISC::CVectorPacked*)ptr);
}
// --------------------------------------------------
@ -1280,19 +1280,19 @@ void CVertexBufferReadWrite::touchVertices (uint first, uint last)
// CVertexBufferRead
// --------------------------------------------------
const NLMISC::CVector* CVertexBufferRead::getVertexCoordPointer(uint idx) const
const NLMISC::CVectorPacked* CVertexBufferRead::getVertexCoordPointer(uint idx) const
{
nlassert (_Parent->checkLockedBuffer());
const uint8* ptr;
ptr=_Parent->_LockedBuffer;
ptr+=(idx*_Parent->_VertexSize);
return((const NLMISC::CVector*)ptr);
return((const NLMISC::CVectorPacked*)ptr);
}
// --------------------------------------------------
const NLMISC::CVector* CVertexBufferRead::getNormalCoordPointer(uint idx) const
const NLMISC::CVectorPacked* CVertexBufferRead::getNormalCoordPointer(uint idx) const
{
nlassert (_Parent->checkLockedBuffer());
const uint8* ptr;
@ -1304,7 +1304,7 @@ const NLMISC::CVector* CVertexBufferRead::getNormalCoordPointer(uint idx) const
ptr=_Parent->_LockedBuffer;
ptr+=_Parent->_Offset[CVertexBuffer::Normal];
ptr+=idx*_Parent->_VertexSize;
return((const NLMISC::CVector*)ptr);
return((const NLMISC::CVectorPacked*)ptr);
}
// --------------------------------------------------

@ -488,7 +488,7 @@ void CLandscapePolyDrawer::drawShadowVolume(uint poly, bool firstPass)
uint i;
CVector2f vertex;
CVector * vertexVB = NULL;
CVectorPacked * vertexVB = NULL;
const CVector cameraPos = Scene->getCam().getPos();
float height = 2000.0;

Loading…
Cancel
Save