diff options
author | Jacek Antonelli | 2008-08-15 23:45:04 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:04 -0500 |
commit | 117e22047c5752352342d64e3fb7ce00a4eb8113 (patch) | |
tree | e32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/newview/llviewerjointmesh_vec.cpp | |
parent | Second Life viewer sources 1.18.0.6 (diff) | |
download | meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2 meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz |
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/newview/llviewerjointmesh_vec.cpp')
-rw-r--r-- | linden/indra/newview/llviewerjointmesh_vec.cpp | 95 |
1 files changed, 95 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..39c50de --- /dev/null +++ b/linden/indra/newview/llviewerjointmesh_vec.cpp | |||
@@ -0,0 +1,95 @@ | |||
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 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
9 | * | ||
10 | * Second Life Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
12 | * to you under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
15 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
17 | * | ||
18 | * There are special exceptions to the terms and conditions of the GPL as | ||
19 | * it is applied to this Source Code. View the full text of the exception | ||
20 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
21 | * online at http://secondlife.com/developers/opensource/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | */ | ||
31 | |||
32 | //----------------------------------------------------------------------------- | ||
33 | // Header Files | ||
34 | //----------------------------------------------------------------------------- | ||
35 | #include "llviewerprecompiledheaders.h" | ||
36 | |||
37 | #include "llviewerjointmesh.h" | ||
38 | |||
39 | #include "llface.h" | ||
40 | #include "llpolymesh.h" | ||
41 | #include "llv4math.h" | ||
42 | #include "llv4matrix3.h" | ||
43 | #include "llv4matrix4.h" | ||
44 | |||
45 | // Generic vectorized code, uses compiler defaults, works well for Altivec | ||
46 | // on PowerPC. | ||
47 | |||
48 | // static | ||
49 | void LLViewerJointMesh::updateGeometryVectorized(LLFace *face, LLPolyMesh *mesh) | ||
50 | { | ||
51 | static LLV4Matrix4 sJointMat[32]; | ||
52 | LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData; | ||
53 | S32 j, joint_num, joint_end = joint_data.count(); | ||
54 | LLV4Vector3 pivot; | ||
55 | |||
56 | //upload joint pivots/matrices | ||
57 | for(j = joint_num = 0; joint_num < joint_end ; ++joint_num ) | ||
58 | { | ||
59 | LLSkinJoint *sj; | ||
60 | const LLMatrix4 * wm = joint_data[joint_num]->mWorldMatrix; | ||
61 | if (NULL == (sj = joint_data[joint_num]->mSkinJoint)) | ||
62 | { | ||
63 | sj = joint_data[++joint_num]->mSkinJoint; | ||
64 | ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToParentJointSkinOffset, pivot); | ||
65 | sJointMat[j++].translate(pivot); | ||
66 | wm = joint_data[joint_num]->mWorldMatrix; | ||
67 | } | ||
68 | ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToJointSkinOffset, pivot); | ||
69 | sJointMat[j++].translate(pivot); | ||
70 | } | ||
71 | |||
72 | F32 weight = F32_MAX; | ||
73 | LLV4Matrix4 blend_mat; | ||
74 | |||
75 | LLStrider<LLVector3> o_vertices; | ||
76 | LLStrider<LLVector3> o_normals; | ||
77 | |||
78 | LLVertexBuffer *buffer = face->mVertexBuffer; | ||
79 | buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset); | ||
80 | buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset); | ||
81 | |||
82 | const F32* weights = mesh->getWeights(); | ||
83 | const LLVector3* coords = mesh->getCoords(); | ||
84 | const LLVector3* normals = mesh->getNormals(); | ||
85 | for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index) | ||
86 | { | ||
87 | if( weight != weights[index]) | ||
88 | { | ||
89 | S32 joint = llfloor(weight = weights[index]); | ||
90 | blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint); | ||
91 | } | ||
92 | blend_mat.multiply(coords[index], o_vertices[index]); | ||
93 | ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]); | ||
94 | } | ||
95 | } | ||