3
0
Fork 0
mirror of https://github.com/JulianGro/overte.git synced 2025-04-30 20:23:20 +02:00

non-exact collisions should work on models with pivots and useOriginalPivot=true

This commit is contained in:
HifiExperiments 2021-01-21 21:05:00 -08:00
parent 030524c3ee
commit bb898aac33
3 changed files with 17 additions and 6 deletions
libraries

View file

@ -463,7 +463,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
}
}
shapeInfo.setParams(type, 0.5f * extents, getCompoundShapeURL() + model->getSnapModelToRegistrationPoint());
adjustShapeInfoByRegistration(shapeInfo);
adjustShapeInfoByRegistration(shapeInfo, model->getSnapModelToRegistrationPoint());
} else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) {
updateModelBounds();
model->updateGeometry();
@ -696,7 +696,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
}
shapeInfo.setParams(type, 0.5f * extents.size(), getModelURL() + model->getSnapModelToRegistrationPoint());
adjustShapeInfoByRegistration(shapeInfo);
adjustShapeInfoByRegistration(shapeInfo, model->getSnapModelToRegistrationPoint());
} else {
EntityItem::computeShapeInfo(shapeInfo);
}

View file

@ -1734,11 +1734,22 @@ float EntityItem::getRadius() const {
return 0.5f * glm::length(getScaledDimensions());
}
void EntityItem::adjustShapeInfoByRegistration(ShapeInfo& info) const {
void EntityItem::adjustShapeInfoByRegistration(ShapeInfo& info, bool includePivot) const {
glm::vec3 offset;
glm::vec3 registrationPoint = getRegistrationPoint();
if (registrationPoint != ENTITY_ITEM_DEFAULT_REGISTRATION_POINT) {
glm::vec3 registration = (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - registrationPoint) * getScaledDimensions();
info.setOffset(registration);
offset += (ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - registrationPoint) * getScaledDimensions();
}
if (includePivot) {
glm::vec3 pivot = getPivot();
if (pivot != ENTITY_ITEM_ZERO_VEC3) {
offset += pivot;
}
}
if (offset != ENTITY_ITEM_ZERO_VEC3) {
info.setOffset(offset);
}
}

View file

@ -404,7 +404,7 @@ public:
// TODO: get rid of users of getRadius()...
float getRadius() const;
virtual void adjustShapeInfoByRegistration(ShapeInfo& info) const;
virtual void adjustShapeInfoByRegistration(ShapeInfo& info, bool includePivot = true) const;
virtual bool contains(const glm::vec3& point) const;
virtual bool isReadyToComputeShape() const { return !isDead(); }