Added debug draw path trace for left and right feet

This commit is contained in:
Anthony Thibault 2016-09-24 12:55:05 -07:00
parent f4c4b3474b
commit 27e6c0f872
4 changed files with 48 additions and 0 deletions

View file

@ -485,6 +485,10 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderMyLookAtVectors, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderOtherLookAtVectors, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false);
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisplayLeftFootTrace, 0, false,
avatar, SLOT(setEnableDebugDrawLeftFootTrace(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisplayRightFootTrace, 0, false,
avatar, SLOT(setEnableDebugDrawRightFootTrace(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawDefaultPose, 0, false,
avatar, SLOT(setEnableDebugDrawDefaultPose(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawAnimPose, 0, false,

View file

@ -88,6 +88,8 @@ namespace MenuOption {
const QString DiskCacheEditor = "Disk Cache Editor";
const QString DisplayCrashOptions = "Display Crash Options";
const QString DisplayHandTargets = "Show Hand Targets";
const QString DisplayLeftFootTrace = "Show Left Foot Trace";
const QString DisplayRightFootTrace = "Show Right Foot Trace";
const QString DisplayModelBounds = "Display Model Bounds";
const QString DisplayModelTriangles = "Display Model Triangles";
const QString DisplayModelElementChildProxies = "Display Model Element Children";

View file

@ -817,6 +817,14 @@ float loadSetting(Settings& settings, const QString& name, float defaultValue) {
return value;
}
void MyAvatar::setEnableDebugDrawLeftFootTrace(bool isEnabled) {
_enableDebugDrawLeftFootTrace = isEnabled;
}
void MyAvatar::setEnableDebugDrawRightFootTrace(bool isEnabled) {
_enableDebugDrawRightFootTrace = isEnabled;
}
void MyAvatar::setEnableDebugDrawDefaultPose(bool isEnabled) {
_enableDebugDrawDefaultPose = isEnabled;
@ -1619,6 +1627,25 @@ void MyAvatar::postUpdate(float deltaTime) {
DebugDraw::getInstance().updateMyAvatarPos(getPosition());
DebugDraw::getInstance().updateMyAvatarRot(getOrientation());
if (_enableDebugDrawLeftFootTrace || _enableDebugDrawRightFootTrace) {
int boneIndex = _enableDebugDrawLeftFootTrace ? getJointIndex("LeftFoot") : getJointIndex("RightFoot");
const glm::vec4 RED(1.0f, 0.0f, 0.0f, 1.0f);
const glm::vec4 WHITE(1.0f, 1.0f, 1.0f, 1.0f);
const glm::vec4 TRANS(1.0f, 1.0f, 1.0f, 0.0f);
static bool colorBit = true;
colorBit = !colorBit;
glm::vec4 color = colorBit ? RED : WHITE;
_debugLineLoop[_debugLineLoopIndex] = DebugDrawVertex(getJointPosition(boneIndex), color);
_debugLineLoopIndex = (_debugLineLoopIndex + 1) % DEBUG_LINE_LOOP_SIZE;
_debugLineLoop[_debugLineLoopIndex] = DebugDrawVertex(getJointPosition(boneIndex), TRANS);
for (size_t prev = DEBUG_LINE_LOOP_SIZE - 1, next = 0; next < DEBUG_LINE_LOOP_SIZE; prev = next, next++) {
if (_debugLineLoop[prev].color.w > 0.0f) {
DebugDraw::getInstance().drawRay(_debugLineLoop[prev].pos, _debugLineLoop[next].pos, _debugLineLoop[prev].color);
}
}
}
}

View file

@ -55,6 +55,8 @@ enum AudioListenerMode {
};
Q_DECLARE_METATYPE(AudioListenerMode);
const size_t DEBUG_LINE_LOOP_SIZE = 1000;
class MyAvatar : public Avatar {
Q_OBJECT
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
@ -303,6 +305,8 @@ public slots:
Q_INVOKABLE void updateMotionBehaviorFromMenu();
void setEnableDebugDrawLeftFootTrace(bool isEnabled);
void setEnableDebugDrawRightFootTrace(bool isEnabled);
void setEnableDebugDrawDefaultPose(bool isEnabled);
void setEnableDebugDrawAnimPose(bool isEnabled);
void setEnableDebugDrawPosition(bool isEnabled);
@ -481,6 +485,8 @@ private:
RigPointer _rig;
bool _prevShouldDrawHead;
bool _enableDebugDrawLeftFootTrace { false };
bool _enableDebugDrawRightFootTrace { false };
bool _enableDebugDrawDefaultPose { false };
bool _enableDebugDrawAnimPose { false };
bool _enableDebugDrawHandControllers { false };
@ -517,6 +523,15 @@ private:
float getEnergy();
void setEnergy(float value);
bool didTeleport();
struct DebugDrawVertex {
DebugDrawVertex() : pos(), color() {}
DebugDrawVertex(const glm::vec3& posIn, const glm::vec4& colorIn) : pos(posIn), color(colorIn) {}
glm::vec3 pos;
glm::vec4 color;
};
DebugDrawVertex _debugLineLoop[DEBUG_LINE_LOOP_SIZE];
size_t _debugLineLoopIndex { 0 };
};
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);