mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 21:47:09 +02:00
Now with less copies.
* AnimSkeleton now returns AnimPoses by const ref. * AnimDebugDraw: uses references to Poses on the stack instead of copies within inner loops. * AnimDebugDraw: Removed unnecessary universal refs in range based for loops.
This commit is contained in:
parent
bb5d061d78
commit
6d5927c0c9
3 changed files with 13 additions and 14 deletions
|
@ -87,11 +87,11 @@ int AnimSkeleton::getNumJoints() const {
|
|||
return _joints.size();
|
||||
}
|
||||
|
||||
AnimPose AnimSkeleton::getAbsoluteBindPose(int jointIndex) const {
|
||||
const AnimPose& AnimSkeleton::getAbsoluteBindPose(int jointIndex) const {
|
||||
return _absoluteBindPoses[jointIndex];
|
||||
}
|
||||
|
||||
AnimPose AnimSkeleton::getRelativeBindPose(int jointIndex) const {
|
||||
const AnimPose& AnimSkeleton::getRelativeBindPose(int jointIndex) const {
|
||||
return _relativeBindPoses[jointIndex];
|
||||
}
|
||||
|
||||
|
|
|
@ -54,10 +54,10 @@ public:
|
|||
int getNumJoints() const;
|
||||
|
||||
// absolute pose, not relative to parent
|
||||
AnimPose getAbsoluteBindPose(int jointIndex) const;
|
||||
const AnimPose& getAbsoluteBindPose(int jointIndex) const;
|
||||
|
||||
// relative to parent pose
|
||||
AnimPose getRelativeBindPose(int jointIndex) const;
|
||||
const AnimPose& getRelativeBindPose(int jointIndex) const;
|
||||
|
||||
int getParentIndex(int jointIndex) const;
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ void AnimDebugDraw::update() {
|
|||
|
||||
// figure out how many verts we will need.
|
||||
int numVerts = 0;
|
||||
for (auto&& iter : _skeletons) {
|
||||
for (auto& iter : _skeletons) {
|
||||
AnimSkeleton::ConstPointer& skeleton = std::get<0>(iter.second);
|
||||
numVerts += skeleton->getNumJoints() * VERTICES_PER_BONE;
|
||||
for (int i = 0; i < skeleton->getNumJoints(); i++) {
|
||||
|
@ -347,7 +347,7 @@ void AnimDebugDraw::update() {
|
|||
}
|
||||
}
|
||||
|
||||
for (auto&& iter : _animNodes) {
|
||||
for (auto& iter : _animNodes) {
|
||||
AnimNode::ConstPointer& animNode = std::get<0>(iter.second);
|
||||
auto poses = animNode->getPosesInternal();
|
||||
numVerts += poses.size() * VERTICES_PER_BONE;
|
||||
|
@ -360,7 +360,7 @@ void AnimDebugDraw::update() {
|
|||
}
|
||||
}
|
||||
|
||||
for (auto&& iter : _poses) {
|
||||
for (auto& iter : _poses) {
|
||||
AnimSkeleton::ConstPointer& skeleton = std::get<0>(iter.second);
|
||||
numVerts += skeleton->getNumJoints() * VERTICES_PER_BONE;
|
||||
for (int i = 0; i < skeleton->getNumJoints(); i++) {
|
||||
|
@ -374,7 +374,7 @@ void AnimDebugDraw::update() {
|
|||
data._vertexBuffer->resize(sizeof(Vertex) * numVerts);
|
||||
Vertex* verts = (Vertex*)data._vertexBuffer->editData();
|
||||
Vertex* v = verts;
|
||||
for (auto&& iter : _skeletons) {
|
||||
for (auto& iter : _skeletons) {
|
||||
AnimSkeleton::ConstPointer& skeleton = std::get<0>(iter.second);
|
||||
AnimPose rootPose = std::get<1>(iter.second);
|
||||
int hipsIndex = skeleton->nameToJointIndex("Hips");
|
||||
|
@ -401,7 +401,7 @@ void AnimDebugDraw::update() {
|
|||
}
|
||||
}
|
||||
|
||||
for (auto&& iter : _animNodes) {
|
||||
for (auto& iter : _animNodes) {
|
||||
AnimNode::ConstPointer& animNode = std::get<0>(iter.second);
|
||||
AnimPose rootPose = std::get<1>(iter.second);
|
||||
if (animNode->_skeleton) {
|
||||
|
@ -439,7 +439,7 @@ void AnimDebugDraw::update() {
|
|||
}
|
||||
}
|
||||
|
||||
for (auto&& iter : _poses) {
|
||||
for (auto& iter : _poses) {
|
||||
AnimSkeleton::ConstPointer& skeleton = std::get<0>(iter.second);
|
||||
AnimPoseVec& poses = std::get<1>(iter.second);
|
||||
AnimPose rootPose = std::get<2>(iter.second);
|
||||
|
@ -453,15 +453,15 @@ void AnimDebugDraw::update() {
|
|||
absAnimPose.resize(skeleton->getNumJoints());
|
||||
|
||||
for (int i = 0; i < skeleton->getNumJoints(); i++) {
|
||||
AnimPose pose = poses[i];
|
||||
const AnimPose& pose = poses[i];
|
||||
|
||||
const float radius = BONE_RADIUS / (pose.scale.x * rootPose.scale.x);
|
||||
|
||||
auto parentIndex = skeleton->getParentIndex(i);
|
||||
if (parentIndex >= 0) {
|
||||
absAnimPose[i] = absAnimPose[parentIndex] * poses[i];
|
||||
absAnimPose[i] = absAnimPose[parentIndex] * pose;
|
||||
} else {
|
||||
absAnimPose[i] = poses[i];
|
||||
absAnimPose[i] = pose;
|
||||
}
|
||||
|
||||
// draw bone
|
||||
|
@ -470,7 +470,6 @@ void AnimDebugDraw::update() {
|
|||
// draw link to parent
|
||||
if (parentIndex >= 0) {
|
||||
assert(parentIndex < skeleton->getNumJoints());
|
||||
AnimPose parentPose = poses[parentIndex];
|
||||
addLink(rootPose, absAnimPose[i], absAnimPose[parentIndex], radius, color, v);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue