Merge pull request #4205 from AndrewMeadows/isentropic

small models get box collision shape
This commit is contained in:
Brad Hefta-Gaub 2015-01-30 18:30:55 -08:00
commit 2eeb2a5ec5
3 changed files with 19 additions and 2 deletions

View file

@ -148,7 +148,8 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
}
glm::quat rotation = getRotation();
if (needsToCallUpdate() && _model->isActive()) {
bool movingOrAnimating = isMoving() || isAnimatingSomething();
if ((movingOrAnimating || _needsInitialSimulation) && _model->isActive()) {
_model->setScaleToFit(true, dimensions);
_model->setSnapModelToRegistrationPoint(true, getRegistrationPoint());
_model->setRotation(rotation);
@ -168,7 +169,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("model->render");
// filter out if not needed to render
if (args && (args->_renderMode == RenderArgs::SHADOW_RENDER_MODE)) {
if (isMoving() || isAnimatingSomething()) {
if (movingOrAnimating) {
_model->renderInScene(alpha, args);
}
} else {

View file

@ -245,6 +245,21 @@ bool ModelEntityItem::needsToCallUpdate() const {
return isAnimatingSomething() ? true : EntityItem::needsToCallUpdate();
}
void ModelEntityItem::computeShapeInfo(ShapeInfo& info) const {
// HACK: Default first first approximation is to boxify the entity... but only if it is small enough.
// The limit here is chosen to something that most avatars could not comfortably fit inside
// to prevent houses from getting boxified... we don't want the things inside houses to
// collide with a house as if it were a giant solid block.
const float MAX_SIZE_FOR_BOXIFICATION_HACK = 3.0f;
float diagonal = glm::length(getDimensionsInMeters());
if (diagonal < MAX_SIZE_FOR_BOXIFICATION_HACK) {
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
info.setBox(halfExtents);
} else {
info.clear();
}
}
void ModelEntityItem::update(const quint64& now) {
// only advance the frame index if we're playing
if (getAnimationIsPlaying()) {

View file

@ -46,6 +46,7 @@ public:
virtual void update(const quint64& now);
virtual bool needsToCallUpdate() const;
void computeShapeInfo(ShapeInfo& info) const;
virtual void debugDump() const;