mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 22:38:33 +02:00
Improvement to bone link rendering when bones are large.
This commit is contained in:
parent
a04f356857
commit
778521f664
1 changed files with 45 additions and 25 deletions
|
@ -250,18 +250,25 @@ static void addLink(const AnimPose& rootPose, const AnimPose& pose,
|
||||||
glm::vec3 boneAxis0 = glm::normalize(pose0.inverse().xformVector(boneAxisWorld));
|
glm::vec3 boneAxis0 = glm::normalize(pose0.inverse().xformVector(boneAxisWorld));
|
||||||
glm::vec3 boneAxis1 = glm::normalize(pose1.inverse().xformVector(boneAxisWorld));
|
glm::vec3 boneAxis1 = glm::normalize(pose1.inverse().xformVector(boneAxisWorld));
|
||||||
|
|
||||||
|
glm::vec3 boneBase = pose0 * (boneAxis0 * radius);
|
||||||
|
glm::vec3 boneTip = pose1 * (boneAxis1 * -radius);
|
||||||
|
|
||||||
|
const int NUM_BASE_CORNERS = 4;
|
||||||
|
|
||||||
|
// make sure there's room between the two bones to draw a nice bone link.
|
||||||
|
if (glm::dot(boneTip - pose0.trans, boneAxisWorld) > glm::dot(boneBase - pose0.trans, boneAxisWorld)) {
|
||||||
|
|
||||||
|
// there is room, so lets draw a nice bone
|
||||||
|
|
||||||
glm::vec3 uAxis, vAxis, wAxis;
|
glm::vec3 uAxis, vAxis, wAxis;
|
||||||
generateBasisVectors(boneAxis0, glm::vec3(1, 0, 0), uAxis, vAxis, wAxis);
|
generateBasisVectors(boneAxis0, glm::vec3(1, 0, 0), uAxis, vAxis, wAxis);
|
||||||
|
|
||||||
const int NUM_BASE_CORNERS = 4;
|
|
||||||
glm::vec3 boneBaseCorners[NUM_BASE_CORNERS];
|
glm::vec3 boneBaseCorners[NUM_BASE_CORNERS];
|
||||||
boneBaseCorners[0] = pose0 * ((uAxis * radius) + (vAxis * radius) + (wAxis * radius));
|
boneBaseCorners[0] = pose0 * ((uAxis * radius) + (vAxis * radius) + (wAxis * radius));
|
||||||
boneBaseCorners[1] = pose0 * ((uAxis * radius) - (vAxis * radius) + (wAxis * radius));
|
boneBaseCorners[1] = pose0 * ((uAxis * radius) - (vAxis * radius) + (wAxis * radius));
|
||||||
boneBaseCorners[2] = pose0 * ((uAxis * radius) - (vAxis * radius) - (wAxis * radius));
|
boneBaseCorners[2] = pose0 * ((uAxis * radius) - (vAxis * radius) - (wAxis * radius));
|
||||||
boneBaseCorners[3] = pose0 * ((uAxis * radius) + (vAxis * radius) - (wAxis * radius));
|
boneBaseCorners[3] = pose0 * ((uAxis * radius) + (vAxis * radius) - (wAxis * radius));
|
||||||
|
|
||||||
glm::vec3 boneTip = pose1 * (boneAxis1 * -radius);
|
|
||||||
|
|
||||||
for (int i = 0; i < NUM_BASE_CORNERS; i++) {
|
for (int i = 0; i < NUM_BASE_CORNERS; i++) {
|
||||||
v->pos = boneBaseCorners[i];
|
v->pos = boneBaseCorners[i];
|
||||||
v->rgba = cyan;
|
v->rgba = cyan;
|
||||||
|
@ -279,6 +286,19 @@ static void addLink(const AnimPose& rootPose, const AnimPose& pose,
|
||||||
v->rgba = cyan;
|
v->rgba = cyan;
|
||||||
v++;
|
v++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// There's no room between the bones to draw the link.
|
||||||
|
// just draw a line between the two bone centers.
|
||||||
|
// We add the same line multiple times, so the vertex count is correct.
|
||||||
|
for (int i = 0; i < NUM_BASE_CORNERS * 2; i++) {
|
||||||
|
v->pos = pose0.trans;
|
||||||
|
v->rgba = cyan;
|
||||||
|
v++;
|
||||||
|
v->pos = pose1.trans;
|
||||||
|
v->rgba = cyan;
|
||||||
|
v++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimDebugDraw::update() {
|
void AnimDebugDraw::update() {
|
||||||
|
|
Loading…
Reference in a new issue