PageRenderTime 89ms CodeModel.GetById 0ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. // Header Files
  31. //-----------------------------------------------------------------------------
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llviewerjointmesh.h"
  34. #include "llface.h"
  35. #include "llpolymesh.h"
  36. #include "llv4math.h"
  37. #include "llv4matrix3.h"
  38. #include "llv4matrix4.h"
  39. // Generic vectorized code, uses compiler defaults, works well for Altivec
  40. // on PowerPC.
  41. // static
  42. void LLViewerJointMesh::updateGeometryVectorized(LLFace *face, LLPolyMesh *mesh)
  43. {
  44. #if 0
  45. static LLV4Matrix4 sJointMat[32];
  46. LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData;
  47. S32 j, joint_num, joint_end = joint_data.count();
  48. LLV4Vector3 pivot;
  49. //upload joint pivots/matrices
  50. for(j = joint_num = 0; joint_num < joint_end ; ++joint_num )
  51. {
  52. LLSkinJoint *sj;
  53. const LLMatrix4 * wm = joint_data[joint_num]->mWorldMatrix;
  54. if (NULL == (sj = joint_data[joint_num]->mSkinJoint))
  55. {
  56. sj = joint_data[++joint_num]->mSkinJoint;
  57. ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToParentJointSkinOffset, pivot);
  58. sJointMat[j++].translate(pivot);
  59. wm = joint_data[joint_num]->mWorldMatrix;
  60. }
  61. ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToJointSkinOffset, pivot);
  62. sJointMat[j++].translate(pivot);
  63. }
  64. F32 weight = F32_MAX;
  65. LLV4Matrix4 blend_mat;
  66. LLStrider<LLVector3> o_vertices;
  67. LLStrider<LLVector3> o_normals;
  68. LLVertexBuffer *buffer = face->mVertexBuffer;
  69. buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset);
  70. buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset);
  71. const F32* weights = mesh->getWeights();
  72. const LLVector3* coords = mesh->getCoords();
  73. const LLVector3* normals = mesh->getNormals();
  74. for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index)
  75. {
  76. if( weight != weights[index])
  77. {
  78. S32 joint = llfloor(weight = weights[index]);
  79. blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint);
  80. }
  81. blend_mat.multiply(coords[index], o_vertices[index]);
  82. ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]);
  83. }
  84. buffer->setBuffer(0);
  85. #endif
  86. }