mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:23:36 +02:00
fix polyvox hull when registration changes.
This commit is contained in:
parent
59804a0f54
commit
dcb720a832
5 changed files with 14 additions and 5 deletions
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue