fix polyvox hull when registration changes.

This commit is contained in:
Seth Alves 2016-03-06 14:09:45 -08:00
parent 59804a0f54
commit dcb720a832
5 changed files with 14 additions and 5 deletions

View file

@ -610,7 +610,6 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
ModelEntityItem::computeShapeInfo(info);
info.setParams(type, 0.5f * getDimensions());
adjustShapeInfoByRegistration(info);
assert(false); // XXX
} else {
updateModelBounds();
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = _model->getCollisionGeometry();
@ -704,6 +703,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
AABox box;
for (int i = 0; i < _points.size(); i++) {
for (int j = 0; j < _points[i].size(); j++) {
// scale so the collision points match the model points
_points[i][j] *= scale;
box += _points[i][j];
}

View file

@ -142,7 +142,7 @@ glm::vec3 RenderablePolyVoxEntityItem::getSurfacePositionAdjustment() const {
glm::mat4 RenderablePolyVoxEntityItem::voxelToLocalMatrix() const {
glm::vec3 scale = getDimensions() / _voxelVolumeSize; // meters / voxel-units
bool success; // TODO -- Does this actually have to happen in world space?
glm::vec3 center = getCenterPosition(success);
glm::vec3 center = getCenterPosition(success); // this handles registrationPoint changes
glm::vec3 position = getPosition(success);
glm::vec3 positionToCenter = center - position;
@ -430,6 +430,13 @@ ShapeType RenderablePolyVoxEntityItem::getShapeType() const {
return SHAPE_TYPE_COMPOUND;
}
void RenderablePolyVoxEntityItem::updateRegistrationPoint(const glm::vec3& value) {
if (value != _registrationPoint) {
_meshDirty = true;
EntityItem::updateRegistrationPoint(value);
}
}
bool RenderablePolyVoxEntityItem::isReadyToComputeShape() {
_meshLock.lockForRead();
if (_meshDirty) {
@ -1231,7 +1238,6 @@ void RenderablePolyVoxEntityItem::computeShapeInfoWorkerAsync() {
_shapeInfoLock.lockForWrite();
_shapeInfo.setParams(SHAPE_TYPE_COMPOUND, collisionModelDimensions, shapeKey);
_shapeInfo.setConvexHulls(points);
adjustShapeInfoByRegistration(_shapeInfo);
_shapeInfoLock.unlock();
_meshLock.lockForWrite();

View file

@ -116,6 +116,8 @@ public:
virtual void rebakeMesh();
virtual void updateRegistrationPoint(const glm::vec3& value);
private:
// The PolyVoxEntityItem class has _voxelData which contains dimensions and compressed voxel data. The dimensions
// may not match _voxelVolumeSize.

View file

@ -320,7 +320,7 @@ public:
virtual void setRotation(glm::quat orientation) { setOrientation(orientation); }
// updateFoo() methods to be used when changes need to be accumulated in the _dirtyFlags
void updateRegistrationPoint(const glm::vec3& value);
virtual void updateRegistrationPoint(const glm::vec3& value);
void updatePosition(const glm::vec3& value);
void updatePositionFromNetwork(const glm::vec3& value);
void updateDimensions(const glm::vec3& value);

View file

@ -16,6 +16,8 @@
#include "ShapeFactory.h"
#include "BulletUtil.h"
btConvexHullShape* ShapeFactory::createConvexHull(const QVector<glm::vec3>& points) {
assert(points.size() > 0);
@ -116,6 +118,5 @@ btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info) {
shape = compound;
}
}
return shape;
}