fix size of rendered bounding capsule

This commit is contained in:
Andrew Meadows 2015-12-14 12:06:11 -08:00
parent 33634cdaa1
commit bab07516f0
3 changed files with 16 additions and 12 deletions

View file

@ -454,7 +454,8 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
bool renderBounding = Menu::getInstance()->isOptionChecked(MenuOption::RenderBoundingCollisionShapes); bool renderBounding = Menu::getInstance()->isOptionChecked(MenuOption::RenderBoundingCollisionShapes);
if (renderBounding && shouldRenderHead(renderArgs) && _skeletonModel.isRenderable()) { if (renderBounding && shouldRenderHead(renderArgs) && _skeletonModel.isRenderable()) {
PROFILE_RANGE_BATCH(batch, __FUNCTION__":skeletonBoundingCollisionShapes"); PROFILE_RANGE_BATCH(batch, __FUNCTION__":skeletonBoundingCollisionShapes");
_skeletonModel.renderBoundingCollisionShapes(*renderArgs->_batch, 0.7f); const float BOUNDING_SHAPE_ALPHA = 0.7f;
_skeletonModel.renderBoundingCollisionShapes(*renderArgs->_batch, getUniformScale(), BOUNDING_SHAPE_ALPHA);
} }
// If this is the avatar being looked at, render a little ball above their head // If this is the avatar being looked at, render a little ball above their head

View file

@ -338,35 +338,38 @@ void SkeletonModel::computeBoundingShape() {
return; return;
} }
_rig->computeAvatarBoundingCapsule(geometry, float radius, height;
_boundingCapsuleRadius, glm::vec3 offset;
_boundingCapsuleHeight, _rig->computeAvatarBoundingCapsule(geometry, radius, height, offset);
_boundingCapsuleLocalOffset); float invScale = 1.0f / _owningAvatar->getUniformScale();
_boundingCapsuleRadius = invScale * radius;
_boundingCapsuleHeight = invScale * height;
_boundingCapsuleLocalOffset = invScale * offset;
} }
void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) { void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float scale, float alpha) {
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
auto deferredLighting = DependencyManager::get<DeferredLightingEffect>(); auto deferredLighting = DependencyManager::get<DeferredLightingEffect>();
// draw a blue sphere at the capsule top point // draw a blue sphere at the capsule top point
glm::vec3 topPoint = _translation + getRotation() * (_boundingCapsuleLocalOffset + (0.5f * _boundingCapsuleHeight) * glm::vec3(0.0f, 1.0f, 0.0f)); glm::vec3 topPoint = _translation + getRotation() * (scale * (_boundingCapsuleLocalOffset + (0.5f * _boundingCapsuleHeight) * Vectors::UNIT_Y));
deferredLighting->renderSolidSphereInstance(batch, deferredLighting->renderSolidSphereInstance(batch,
Transform().setTranslation(topPoint).postScale(_boundingCapsuleRadius), Transform().setTranslation(topPoint).postScale(scale * _boundingCapsuleRadius),
glm::vec4(0.6f, 0.6f, 0.8f, alpha)); glm::vec4(0.6f, 0.6f, 0.8f, alpha));
// draw a yellow sphere at the capsule bottom point // draw a yellow sphere at the capsule bottom point
glm::vec3 bottomPoint = topPoint - glm::vec3(0.0f, _boundingCapsuleHeight, 0.0f); glm::vec3 bottomPoint = topPoint - glm::vec3(0.0f, scale * _boundingCapsuleHeight, 0.0f);
glm::vec3 axis = topPoint - bottomPoint; glm::vec3 axis = topPoint - bottomPoint;
deferredLighting->renderSolidSphereInstance(batch, deferredLighting->renderSolidSphereInstance(batch,
Transform().setTranslation(bottomPoint).postScale(_boundingCapsuleRadius), Transform().setTranslation(bottomPoint).postScale(scale * _boundingCapsuleRadius),
glm::vec4(0.8f, 0.8f, 0.6f, alpha)); glm::vec4(0.8f, 0.8f, 0.6f, alpha));
// draw a green cylinder between the two points // draw a green cylinder between the two points
glm::vec3 origin(0.0f); glm::vec3 origin(0.0f);
batch.setModelTransform(Transform().setTranslation(bottomPoint)); batch.setModelTransform(Transform().setTranslation(bottomPoint));
deferredLighting->bindSimpleProgram(batch); deferredLighting->bindSimpleProgram(batch);
Avatar::renderJointConnectingCone(batch, origin, axis, _boundingCapsuleRadius, _boundingCapsuleRadius, Avatar::renderJointConnectingCone(batch, origin, axis, scale * _boundingCapsuleRadius, scale * _boundingCapsuleRadius,
glm::vec4(0.6f, 0.8f, 0.6f, alpha)); glm::vec4(0.6f, 0.8f, 0.6f, alpha));
} }

View file

@ -89,7 +89,7 @@ public:
/// \return whether or not the head was found. /// \return whether or not the head was found.
glm::vec3 getDefaultEyeModelPosition() const; glm::vec3 getDefaultEyeModelPosition() const;
void renderBoundingCollisionShapes(gpu::Batch& batch, float alpha); void renderBoundingCollisionShapes(gpu::Batch& batch, float scale, float alpha);
float getBoundingCapsuleRadius() const { return _boundingCapsuleRadius; } float getBoundingCapsuleRadius() const { return _boundingCapsuleRadius; }
float getBoundingCapsuleHeight() const { return _boundingCapsuleHeight; } float getBoundingCapsuleHeight() const { return _boundingCapsuleHeight; }
const glm::vec3 getBoundingCapsuleOffset() const { return _boundingCapsuleLocalOffset; } const glm::vec3 getBoundingCapsuleOffset() const { return _boundingCapsuleLocalOffset; }