diff options
Diffstat (limited to 'linden/indra/newview/llviewerjointmesh_vec.cpp')
-rw-r--r-- | linden/indra/newview/llviewerjointmesh_vec.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewerjointmesh_vec.cpp b/linden/indra/newview/llviewerjointmesh_vec.cpp new file mode 100644 index 0000000..4d52361 --- /dev/null +++ b/linden/indra/newview/llviewerjointmesh_vec.cpp | |||
@@ -0,0 +1,97 @@ | |||
1 | /** | ||
2 | * @file llviewerjointmesh.cpp | ||
3 | * @brief LLV4 math class implementation with LLViewerJointMesh class | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * Second Life Viewer Source Code | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | //----------------------------------------------------------------------------- | ||
30 | // Header Files | ||
31 | //----------------------------------------------------------------------------- | ||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
34 | #include "llviewerjointmesh.h" | ||
35 | |||
36 | #include "llface.h" | ||
37 | #include "llpolymesh.h" | ||
38 | #include "llv4math.h" | ||
39 | #include "llv4matrix3.h" | ||
40 | #include "llv4matrix4.h" | ||
41 | |||
42 | // *NOTE: This is the fallback code for vectorized joint mesh skinning. | ||
43 | // For builds that must support non-SSE x86 code (Windows, perhaps Linux) | ||
44 | // SSE code generation should be disabled for this file. | ||
45 | // | ||
46 | // For builds that run on processors that always have SSE (Mac), | ||
47 | // SSE code generation can be enabled. JC | ||
48 | |||
49 | static LLV4Matrix4 sJointMat[32]; | ||
50 | |||
51 | // static | ||
52 | void LLViewerJointMesh::updateGeometryVectorized(LLFace *face, LLPolyMesh *mesh) | ||
53 | { | ||
54 | LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData; | ||
55 | S32 j, joint_num, joint_end = joint_data.count(); | ||
56 | LLV4Vector3 pivot; | ||
57 | |||
58 | //upload joint pivots/matrices | ||
59 | for(j = joint_num = 0; joint_num < joint_end ; ++joint_num ) | ||
60 | { | ||
61 | LLSkinJoint *sj; | ||
62 | const LLMatrix4 * wm = joint_data[joint_num]->mWorldMatrix; | ||
63 | if (NULL == (sj = joint_data[joint_num]->mSkinJoint)) | ||
64 | { | ||
65 | sj = joint_data[++joint_num]->mSkinJoint; | ||
66 | ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToParentJointSkinOffset, pivot); | ||
67 | sJointMat[j++].translate(pivot); | ||
68 | wm = joint_data[joint_num]->mWorldMatrix; | ||
69 | } | ||
70 | ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToJointSkinOffset, pivot); | ||
71 | sJointMat[j++].translate(pivot); | ||
72 | } | ||
73 | |||
74 | F32 weight = F32_MAX; | ||
75 | LLV4Matrix4 blend_mat; | ||
76 | |||
77 | LLStrider<LLVector3> o_vertices; | ||
78 | LLStrider<LLVector3> o_normals; | ||
79 | |||
80 | LLVertexBuffer *buffer = face->mVertexBuffer; | ||
81 | buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset); | ||
82 | buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset); | ||
83 | |||
84 | const F32* weights = mesh->getWeights(); | ||
85 | const LLVector3* coords = mesh->getCoords(); | ||
86 | const LLVector3* normals = mesh->getNormals(); | ||
87 | for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index) | ||
88 | { | ||
89 | if( weight != weights[index]) | ||
90 | { | ||
91 | S32 joint = llfloor(weight = weights[index]); | ||
92 | blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint); | ||
93 | } | ||
94 | blend_mat.multiply(coords[index], o_vertices[index]); | ||
95 | ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]); | ||
96 | } | ||
97 | } | ||