PageRenderTime 46ms CodeModel.GetById 20ms app.highlight 8ms RepoModel.GetById 12ms app.codeStats 0ms

/indra/newview/llviewerjointmesh_vec.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 97 lines | 51 code | 11 blank | 35 comment | 6 complexity | 520cffc2c118aacc4eb21409b795c30f MD5 | raw file
 1/** 
 2 * @file llviewerjointmesh_vec.cpp
 3 * @brief Compiler-generated vectorized joint skinning code, works well on
 4 * Altivec processors (PowerPC Mac)
 5 *
 6 * *NOTE: See llv4math.h for notes on SSE/Altivec vector code.
 7 *
 8 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 9 * Second Life Viewer Source Code
10 * Copyright (C) 2010, Linden Research, Inc.
11 * 
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation;
15 * version 2.1 of the License only.
16 * 
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 * Lesser General Public License for more details.
21 * 
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
25 * 
26 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
27 * $/LicenseInfo$
28 */
29
30//-----------------------------------------------------------------------------
31// Header Files
32//-----------------------------------------------------------------------------
33#include "llviewerprecompiledheaders.h"
34
35#include "llviewerjointmesh.h"
36
37#include "llface.h"
38#include "llpolymesh.h"
39#include "llv4math.h"
40#include "llv4matrix3.h"
41#include "llv4matrix4.h"
42
43// Generic vectorized code, uses compiler defaults, works well for Altivec
44// on PowerPC.
45
46// static
47void LLViewerJointMesh::updateGeometryVectorized(LLFace *face, LLPolyMesh *mesh)
48{
49#if 0
50	static LLV4Matrix4	sJointMat[32];
51	LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData;
52	S32 j, joint_num, joint_end = joint_data.count();
53	LLV4Vector3 pivot;
54
55	//upload joint pivots/matrices
56	for(j = joint_num = 0; joint_num < joint_end ; ++joint_num )
57	{
58		LLSkinJoint *sj;
59		const LLMatrix4 *	wm = joint_data[joint_num]->mWorldMatrix;
60		if (NULL == (sj = joint_data[joint_num]->mSkinJoint))
61		{
62				sj = joint_data[++joint_num]->mSkinJoint;
63				((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToParentJointSkinOffset, pivot);
64				sJointMat[j++].translate(pivot);
65				wm = joint_data[joint_num]->mWorldMatrix;
66		}
67		((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToJointSkinOffset, pivot);
68		sJointMat[j++].translate(pivot);
69	}
70
71	F32					weight		= F32_MAX;
72	LLV4Matrix4			blend_mat;
73
74	LLStrider<LLVector3> o_vertices;
75	LLStrider<LLVector3> o_normals;
76
77	LLVertexBuffer *buffer = face->mVertexBuffer;
78	buffer->getVertexStrider(o_vertices,  mesh->mFaceVertexOffset);
79	buffer->getNormalStrider(o_normals,   mesh->mFaceVertexOffset);
80
81	const F32*			weights			= mesh->getWeights();
82	const LLVector3*	coords			= mesh->getCoords();
83	const LLVector3*	normals			= mesh->getNormals();
84	for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index)
85	{
86		if( weight != weights[index])
87		{
88			S32 joint = llfloor(weight = weights[index]);
89			blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint);
90		}
91		blend_mat.multiply(coords[index], o_vertices[index]);
92		((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]);
93	}
94
95	buffer->setBuffer(0);
96#endif
97}