diff options
author | Dave Parks <davep@lindenlab.com> | 2010-10-05 16:55:41 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2010-10-05 16:55:41 -0500 |
commit | 98d622551d9466d1153dedfbdd721becf8c38cd9 (patch) | |
tree | edcb74137f1bb88a0566a9531dde64897b44802a /indra/llprimitive | |
parent | 70b2ace13130b3a0d881fb87cff0167ed811f560 (diff) | |
parent | 1f00747cd2accbe1b243e5c23f6e74a061a22bfa (diff) |
merge
Diffstat (limited to 'indra/llprimitive')
-rw-r--r-- | indra/llprimitive/llmodel.cpp | 25 | ||||
-rw-r--r-- | indra/llprimitive/llmodel.h | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 9e3d9704ae..1cada567e9 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1724,4 +1724,29 @@ LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) } } +void LLModel::setPhysicsShape(const LLModel::physics_shape& shape) +{ + mPhysicsShape = shape; + + mHullCenter.resize(mPhysicsShape.size()); + mPhysicsPoints = 0; + mPhysicsCenter.clear(); + + for (U32 i = 0; i < shape.size(); ++i) + { + LLVector3 cur_center; + + for (U32 j = 0; j < shape[i].size(); ++j) + { + cur_center += shape[i][j]; + } + mPhysicsCenter += cur_center; + cur_center *= 1.f/shape[i].size(); + mHullCenter[i] = cur_center; + mPhysicsPoints += shape[i].size(); + } + + mPhysicsCenter *= 1.f/mPhysicsPoints; +} + diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index e6696b984f..ec21ef2fcd 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -160,6 +160,7 @@ public: //physics shape physics_shape mPhysicsShape; + void setPhysicsShape(const physics_shape& shape); LLVector3 mPhysicsCenter; std::vector<LLVector3> mHullCenter; |