mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 01:13:32 +02:00
pull from andrew's branch
This commit is contained in:
commit
2a87eb9ce1
15 changed files with 97 additions and 237 deletions
|
@ -274,63 +274,50 @@ void RenderableModelEntityItem::setCollisionModelURL(const QString& url) {
|
|||
}
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::hasCollisionModel() const {
|
||||
if (_model) {
|
||||
return ! _model->getCollisionURL().isEmpty();
|
||||
} else {
|
||||
return !_collisionModelURL.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
const QString& RenderableModelEntityItem::getCollisionModelURL() const {
|
||||
// assert (!_model || _collisionModelURL == _model->getCollisionURL().toString());
|
||||
return _collisionModelURL;
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::isReadyToComputeShape() {
|
||||
ShapeType type = getShapeType();
|
||||
if (type == SHAPE_TYPE_COMPOUND) {
|
||||
|
||||
if (_shapeType != SHAPE_TYPE_COMPOUND && _shapeType != SHAPE_TYPE_CONVEX_HULL) {
|
||||
return true;
|
||||
if (!_model) {
|
||||
return false; // hmm...
|
||||
}
|
||||
|
||||
assert(!_model->getCollisionURL().isEmpty());
|
||||
|
||||
if (_model->getURL().isEmpty()) {
|
||||
// we need a render geometry with a scale to proceed, so give up.
|
||||
return false;
|
||||
}
|
||||
|
||||
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = _model->getCollisionGeometry();
|
||||
const QSharedPointer<NetworkGeometry> renderNetworkGeometry = _model->getGeometry();
|
||||
|
||||
if ((! collisionNetworkGeometry.isNull() && collisionNetworkGeometry->isLoadedWithTextures()) &&
|
||||
(! renderNetworkGeometry.isNull() && renderNetworkGeometry->isLoadedWithTextures())) {
|
||||
// we have both URLs AND both geometries AND they are both fully loaded.
|
||||
return true;
|
||||
}
|
||||
|
||||
// the model is still being downloaded.
|
||||
std::cout << "adebug still being downloaded" << std::endl; // adebug
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_model) {
|
||||
return false; // hmm...
|
||||
}
|
||||
|
||||
if (_model->getCollisionURL().isEmpty()) {
|
||||
// no collision-model url, so we're ready to compute a shape (of type None).
|
||||
return true;
|
||||
}
|
||||
if (_model->getURL().isEmpty()) {
|
||||
// we need a render geometry with a scale to proceed, so give up.
|
||||
return true;
|
||||
}
|
||||
|
||||
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = _model->getCollisionGeometry();
|
||||
const QSharedPointer<NetworkGeometry> renderNetworkGeometry = _model->getGeometry();
|
||||
|
||||
if ((! collisionNetworkGeometry.isNull() && collisionNetworkGeometry->isLoadedWithTextures()) &&
|
||||
(! renderNetworkGeometry.isNull() && renderNetworkGeometry->isLoadedWithTextures())) {
|
||||
// we have both URLs AND both geometries AND they are both fully loaded.
|
||||
return true;
|
||||
}
|
||||
|
||||
// the model is still being downloaded.
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||
if (_shapeType != SHAPE_TYPE_COMPOUND && _shapeType != SHAPE_TYPE_CONVEX_HULL) {
|
||||
info.setParams(getShapeType(), 0.5f * getDimensions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (_model->getCollisionURL().isEmpty() || _model->getURL().isEmpty()) {
|
||||
info.setParams(getShapeType(), 0.5f * getDimensions());
|
||||
ShapeType type = getShapeType();
|
||||
if (type != SHAPE_TYPE_COMPOUND) {
|
||||
ModelEntityItem::computeShapeInfo(info);
|
||||
info.setParams(_shapeType, 0.5f * getDimensions());
|
||||
} else {
|
||||
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = _model->getCollisionGeometry();
|
||||
const FBXGeometry& collisionGeometry = collisionNetworkGeometry->getFBXGeometry();
|
||||
|
||||
// should never fall in here when collision model not fully loaded
|
||||
// hence we assert collisionNetworkGeometry is not NULL
|
||||
assert(!collisionNetworkGeometry.isNull());
|
||||
|
||||
const FBXGeometry& collisionGeometry = collisionNetworkGeometry->getFBXGeometry();
|
||||
const QSharedPointer<NetworkGeometry> renderNetworkGeometry = _model->getGeometry();
|
||||
const FBXGeometry& renderGeometry = renderNetworkGeometry->getFBXGeometry();
|
||||
|
||||
|
@ -424,18 +411,8 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
|||
}
|
||||
|
||||
glm::vec3 collisionModelDimensions = box.getDimensions();
|
||||
info.setParams(getShapeType(), collisionModelDimensions, _collisionModelURL);
|
||||
info.setParams(_shapeType, collisionModelDimensions, _collisionModelURL);
|
||||
info.setConvexHulls(_points);
|
||||
}
|
||||
}
|
||||
|
||||
ShapeType RenderableModelEntityItem::getShapeType() const {
|
||||
// XXX make hull an option in edit.js ?
|
||||
if (!_model || _model->getCollisionURL().isEmpty()) {
|
||||
return _shapeType;
|
||||
} else if (_points.size() == 1) {
|
||||
return SHAPE_TYPE_CONVEX_HULL;
|
||||
} else {
|
||||
return SHAPE_TYPE_COMPOUND;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,12 +53,9 @@ public:
|
|||
bool needsToCallUpdate() const;
|
||||
|
||||
virtual void setCollisionModelURL(const QString& url);
|
||||
virtual bool hasCollisionModel() const;
|
||||
virtual const QString& getCollisionModelURL() const;
|
||||
|
||||
bool isReadyToComputeShape();
|
||||
void computeShapeInfo(ShapeInfo& info);
|
||||
ShapeType getShapeType() const;
|
||||
|
||||
private:
|
||||
void remapTextures();
|
||||
|
|
|
@ -192,7 +192,7 @@ void buildStringToShapeTypeLookup() {
|
|||
stringToShapeTypeLookup["box"] = SHAPE_TYPE_BOX;
|
||||
stringToShapeTypeLookup["sphere"] = SHAPE_TYPE_SPHERE;
|
||||
stringToShapeTypeLookup["ellipsoid"] = SHAPE_TYPE_ELLIPSOID;
|
||||
stringToShapeTypeLookup["convex-hull"] = SHAPE_TYPE_CONVEX_HULL;
|
||||
stringToShapeTypeLookup["convex-hull"] = SHAPE_TYPE_COMPOUND;
|
||||
stringToShapeTypeLookup["plane"] = SHAPE_TYPE_PLANE;
|
||||
stringToShapeTypeLookup["compound"] = SHAPE_TYPE_COMPOUND;
|
||||
stringToShapeTypeLookup["capsule-x"] = SHAPE_TYPE_CAPSULE_X;
|
||||
|
|
|
@ -282,6 +282,16 @@ void ModelEntityItem::updateShapeType(ShapeType type) {
|
|||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
ShapeType ModelEntityItem::getShapeType() const {
|
||||
if (_shapeType == SHAPE_TYPE_COMPOUND) {
|
||||
return hasCollisionModel() ? SHAPE_TYPE_COMPOUND : SHAPE_TYPE_NONE;
|
||||
}
|
||||
else {
|
||||
return _shapeType;
|
||||
}
|
||||
}
|
||||
|
||||
void ModelEntityItem::setCollisionModelURL(const QString& url) {
|
||||
if (_collisionModelURL != url) {
|
||||
_collisionModelURL = url;
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
virtual void debugDump() const;
|
||||
|
||||
void updateShapeType(ShapeType type);
|
||||
virtual ShapeType getShapeType() const { return _shapeType; }
|
||||
virtual ShapeType getShapeType() const;
|
||||
|
||||
// TODO: Move these to subclasses, or other appropriate abstraction
|
||||
// getters/setters applicable to models and particles
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
const QString& getModelURL() const { return _modelURL; }
|
||||
|
||||
static const QString DEFAULT_COLLISION_MODEL_URL;
|
||||
virtual const QString& getCollisionModelURL() const { return _collisionModelURL; }
|
||||
const QString& getCollisionModelURL() const { return _collisionModelURL; }
|
||||
|
||||
bool hasAnimation() const { return !_animationURL.isEmpty(); }
|
||||
static const QString DEFAULT_ANIMATION_URL;
|
||||
|
|
|
@ -245,7 +245,6 @@ void DynamicCharacterController::setEnabled(bool enabled) {
|
|||
// Don't bother clearing REMOVE bit since it might be paired with an UPDATE_SHAPE bit.
|
||||
// Setting the ADD bit here works for all cases so we don't even bother checking other bits.
|
||||
_pendingFlags |= PENDING_FLAG_ADD_TO_SIMULATION;
|
||||
setHovering(true);
|
||||
} else {
|
||||
if (_dynamicsWorld) {
|
||||
_pendingFlags |= PENDING_FLAG_REMOVE_FROM_SIMULATION;
|
||||
|
@ -253,6 +252,7 @@ void DynamicCharacterController::setEnabled(bool enabled) {
|
|||
_pendingFlags &= ~ PENDING_FLAG_ADD_TO_SIMULATION;
|
||||
_isOnGround = false;
|
||||
}
|
||||
setHovering(true);
|
||||
_enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,6 +201,8 @@ bool EntityMotionState::shouldSendUpdate(uint32_t simulationFrame) {
|
|||
|
||||
|
||||
void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_t frame) {
|
||||
const int NUM_NONMOVING_UPDATES_TO_SEND = 3;
|
||||
|
||||
if (!_entity->isKnownID()) {
|
||||
return; // never update entities that are unknown
|
||||
}
|
||||
|
@ -251,11 +253,11 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
|||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
QString myNodeID = nodeList->getSessionUUID().toString();
|
||||
QString simulatorID = _entity->getSimulatorID();
|
||||
if (simulatorID.isEmpty() && !(zeroSpin && zeroSpin)) {
|
||||
if (simulatorID.isEmpty() && !(zeroSpeed && zeroSpin)) {
|
||||
// The object is moving and nobody thinks they own the motion. set this Node as the simulator
|
||||
_entity->setSimulatorID(myNodeID);
|
||||
properties.setSimulatorID(myNodeID);
|
||||
} else if (simulatorID == myNodeID && zeroSpin && _numNonMovingUpdates == 3) {
|
||||
} else if (simulatorID == myNodeID && _numNonMovingUpdates == NUM_NONMOVING_UPDATES_TO_SEND) {
|
||||
// we are the simulator and the object has stopped. give up "simulator" status
|
||||
_entity->setSimulatorID("");
|
||||
properties.setSimulatorID("");
|
||||
|
@ -287,7 +289,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
|||
properties.setLastEdited(_entity->getLastEdited());
|
||||
}
|
||||
|
||||
if (EntityItem::getSendPhysicsUpdates() && _numNonMovingUpdates < 4) {
|
||||
if (EntityItem::getSendPhysicsUpdates() && _numNonMovingUpdates <= NUM_NONMOVING_UPDATES_TO_SEND) {
|
||||
EntityItemID id(_entity->getID());
|
||||
EntityEditPacketSender* entityPacketSender = static_cast<EntityEditPacketSender*>(packetSender);
|
||||
#ifdef WANT_DEBUG
|
||||
|
|
|
@ -14,107 +14,6 @@
|
|||
#include "ShapeInfoUtil.h"
|
||||
#include "BulletUtil.h"
|
||||
|
||||
int ShapeInfoUtil::toBulletShapeType(int shapeInfoType) {
|
||||
int bulletShapeType = INVALID_SHAPE_PROXYTYPE;
|
||||
switch(shapeInfoType) {
|
||||
case SHAPE_TYPE_BOX:
|
||||
bulletShapeType = BOX_SHAPE_PROXYTYPE;
|
||||
break;
|
||||
case SHAPE_TYPE_SPHERE:
|
||||
bulletShapeType = SPHERE_SHAPE_PROXYTYPE;
|
||||
break;
|
||||
case SHAPE_TYPE_CAPSULE_Y:
|
||||
bulletShapeType = CAPSULE_SHAPE_PROXYTYPE;
|
||||
break;
|
||||
case SHAPE_TYPE_CONVEX_HULL:
|
||||
bulletShapeType = CONVEX_HULL_SHAPE_PROXYTYPE;
|
||||
break;
|
||||
case SHAPE_TYPE_COMPOUND:
|
||||
bulletShapeType = COMPOUND_SHAPE_PROXYTYPE;
|
||||
break;
|
||||
}
|
||||
return bulletShapeType;
|
||||
}
|
||||
|
||||
int ShapeInfoUtil::fromBulletShapeType(int bulletShapeType) {
|
||||
int shapeInfoType = SHAPE_TYPE_NONE;
|
||||
switch(bulletShapeType) {
|
||||
case BOX_SHAPE_PROXYTYPE:
|
||||
shapeInfoType = SHAPE_TYPE_BOX;
|
||||
break;
|
||||
case SPHERE_SHAPE_PROXYTYPE:
|
||||
shapeInfoType = SHAPE_TYPE_SPHERE;
|
||||
break;
|
||||
case CAPSULE_SHAPE_PROXYTYPE:
|
||||
shapeInfoType = SHAPE_TYPE_CAPSULE_Y;
|
||||
break;
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
shapeInfoType = SHAPE_TYPE_CONVEX_HULL;
|
||||
break;
|
||||
case COMPOUND_SHAPE_PROXYTYPE:
|
||||
shapeInfoType = SHAPE_TYPE_COMPOUND;
|
||||
break;
|
||||
}
|
||||
return shapeInfoType;
|
||||
}
|
||||
|
||||
void ShapeInfoUtil::collectInfoFromShape(const btCollisionShape* shape, ShapeInfo& info) {
|
||||
if (shape) {
|
||||
int type = ShapeInfoUtil::fromBulletShapeType(shape->getShapeType());
|
||||
switch(type) {
|
||||
case SHAPE_TYPE_BOX: {
|
||||
const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
|
||||
info.setBox(bulletToGLM(boxShape->getHalfExtentsWithMargin()));
|
||||
}
|
||||
break;
|
||||
case SHAPE_TYPE_SPHERE: {
|
||||
const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
|
||||
info.setSphere(sphereShape->getRadius());
|
||||
}
|
||||
break;
|
||||
case SHAPE_TYPE_CONVEX_HULL: {
|
||||
const btConvexHullShape* convexHullShape = static_cast<const btConvexHullShape*>(shape);
|
||||
const int numPoints = convexHullShape->getNumPoints();
|
||||
const btVector3* btPoints = convexHullShape->getUnscaledPoints();
|
||||
QVector<QVector<glm::vec3>> points;
|
||||
QVector<glm::vec3> childPoints;
|
||||
for (int i = 0; i < numPoints; i++) {
|
||||
glm::vec3 point(btPoints->getX(), btPoints->getY(), btPoints->getZ());
|
||||
childPoints << point;
|
||||
}
|
||||
points << childPoints;
|
||||
info.setConvexHulls(points);
|
||||
}
|
||||
break;
|
||||
case SHAPE_TYPE_COMPOUND: {
|
||||
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
|
||||
const int numChildShapes = compoundShape->getNumChildShapes();
|
||||
QVector<QVector<glm::vec3>> points;
|
||||
for (int i = 0; i < numChildShapes; i ++) {
|
||||
const btCollisionShape* childShape = compoundShape->getChildShape(i);
|
||||
const btConvexHullShape* convexHullShape = static_cast<const btConvexHullShape*>(childShape);
|
||||
const int numPoints = convexHullShape->getNumPoints();
|
||||
const btVector3* btPoints = convexHullShape->getUnscaledPoints();
|
||||
|
||||
QVector<glm::vec3> childPoints;
|
||||
for (int j = 0; j < numPoints; j++) {
|
||||
glm::vec3 point(btPoints->getX(), btPoints->getY(), btPoints->getZ());
|
||||
childPoints << point;
|
||||
}
|
||||
points << childPoints;
|
||||
}
|
||||
info.setConvexHulls(points);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
info.clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
info.clear();
|
||||
}
|
||||
}
|
||||
|
||||
btCollisionShape* ShapeInfoUtil::createShapeFromInfo(const ShapeInfo& info) {
|
||||
btCollisionShape* shape = NULL;
|
||||
|
@ -135,33 +34,34 @@ btCollisionShape* ShapeInfoUtil::createShapeFromInfo(const ShapeInfo& info) {
|
|||
shape = new btCapsuleShape(radius, height);
|
||||
}
|
||||
break;
|
||||
case SHAPE_TYPE_CONVEX_HULL: {
|
||||
auto hull = new btConvexHullShape();
|
||||
const QVector<QVector<glm::vec3>>& points = info.getPoints();
|
||||
foreach (glm::vec3 point, points[0]) {
|
||||
btVector3 btPoint(point[0], point[1], point[2]);
|
||||
hull->addPoint(btPoint, false);
|
||||
}
|
||||
hull->recalcLocalAabb();
|
||||
shape = hull;
|
||||
}
|
||||
break;
|
||||
case SHAPE_TYPE_COMPOUND: {
|
||||
auto compound = new btCompoundShape();
|
||||
const QVector<QVector<glm::vec3>>& points = info.getPoints();
|
||||
|
||||
btTransform trans;
|
||||
trans.setIdentity();
|
||||
foreach (QVector<glm::vec3> hullPoints, points) {
|
||||
uint32_t numSubShapes = info.getNumSubShapes();
|
||||
if (numSubShapes == 1) {
|
||||
auto hull = new btConvexHullShape();
|
||||
foreach (glm::vec3 point, hullPoints) {
|
||||
const QVector<QVector<glm::vec3>>& points = info.getPoints();
|
||||
foreach (glm::vec3 point, points[0]) {
|
||||
btVector3 btPoint(point[0], point[1], point[2]);
|
||||
hull->addPoint(btPoint, false);
|
||||
}
|
||||
hull->recalcLocalAabb();
|
||||
compound->addChildShape (trans, hull);
|
||||
shape = hull;
|
||||
} else {
|
||||
assert(numSubShapes > 1);
|
||||
auto compound = new btCompoundShape();
|
||||
btTransform trans;
|
||||
trans.setIdentity();
|
||||
foreach (QVector<glm::vec3> hullPoints, points) {
|
||||
auto hull = new btConvexHullShape();
|
||||
foreach (glm::vec3 point, hullPoints) {
|
||||
btVector3 btPoint(point[0], point[1], point[2]);
|
||||
hull->addPoint(btPoint, false);
|
||||
}
|
||||
hull->recalcLocalAabb();
|
||||
compound->addChildShape (trans, hull);
|
||||
}
|
||||
shape = compound;
|
||||
}
|
||||
shape = compound;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -19,16 +19,10 @@
|
|||
|
||||
// translates between ShapeInfo and btShape
|
||||
|
||||
// TODO: rename this to ShapeFactory
|
||||
namespace ShapeInfoUtil {
|
||||
|
||||
// XXX is collectInfoFromShape no longer strictly needed?
|
||||
void collectInfoFromShape(const btCollisionShape* shape, ShapeInfo& info);
|
||||
|
||||
btCollisionShape* createShapeFromInfo(const ShapeInfo& info);
|
||||
|
||||
// TODO? just use bullet shape types everywhere?
|
||||
int toBulletShapeType(int shapeInfoType);
|
||||
int fromBulletShapeType(int bulletShapeType);
|
||||
};
|
||||
|
||||
#endif // hifi_ShapeInfoUtil_h
|
||||
|
|
|
@ -35,7 +35,7 @@ btCollisionShape* ShapeManager::getShape(const ShapeInfo& info) {
|
|||
// Very small or large objects are not supported.
|
||||
float diagonal = 4.0f * glm::length2(info.getHalfExtents());
|
||||
const float MIN_SHAPE_DIAGONAL_SQUARED = 3.0e-4f; // 1 cm cube
|
||||
const float MAX_SHAPE_DIAGONAL_SQUARED = 3.0e6f; // 1000 m cube
|
||||
//const float MAX_SHAPE_DIAGONAL_SQUARED = 3.0e6f; // 1000 m cube
|
||||
if (diagonal < MIN_SHAPE_DIAGONAL_SQUARED /* || diagonal > MAX_SHAPE_DIAGONAL_SQUARED*/ ) {
|
||||
// qCDebug(physics) << "ShapeManager::getShape -- not making shape due to size" << diagonal;
|
||||
return NULL;
|
||||
|
@ -104,11 +104,9 @@ void ShapeManager::collectGarbage() {
|
|||
ShapeReference* shapeRef = _shapeMap.find(key);
|
||||
if (shapeRef && shapeRef->refCount == 0) {
|
||||
// if the shape we're about to delete is compound, delete the children first.
|
||||
auto shapeType = ShapeInfoUtil::fromBulletShapeType(shapeRef->shape->getShapeType());
|
||||
if (shapeType == SHAPE_TYPE_COMPOUND) {
|
||||
if (shapeRef->shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) {
|
||||
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shapeRef->shape);
|
||||
const int numChildShapes = compoundShape->getNumChildShapes();
|
||||
QVector<QVector<glm::vec3>> points;
|
||||
for (int i = 0; i < numChildShapes; i ++) {
|
||||
const btCollisionShape* childShape = compoundShape->getChildShape(i);
|
||||
delete childShape;
|
||||
|
|
|
@ -151,7 +151,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
|
|||
|
||||
// create a new RenderPipeline with the same shader side and the mirrorState
|
||||
auto mirrorPipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, mirrorState));
|
||||
auto it = insert(value_type(mirrorKey.getRaw(), RenderPipeline(mirrorPipeline, locations)));
|
||||
insert(value_type(mirrorKey.getRaw(), RenderPipeline(mirrorPipeline, locations)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,6 @@ void ShapeInfo::setParams(ShapeType type, const glm::vec3& halfExtents, QString
|
|||
_halfExtents = glm::vec3(radius);
|
||||
break;
|
||||
}
|
||||
case SHAPE_TYPE_CONVEX_HULL:
|
||||
_url = QUrl(url);
|
||||
// halfExtents aren't used by convex-hull or compound convex-hull except as part of
|
||||
// the generation of the key for the ShapeManager.
|
||||
_halfExtents = halfExtents;
|
||||
break;
|
||||
case SHAPE_TYPE_COMPOUND:
|
||||
_url = QUrl(url);
|
||||
_halfExtents = halfExtents;
|
||||
|
@ -78,12 +72,8 @@ void ShapeInfo::setEllipsoid(const glm::vec3& halfExtents) {
|
|||
}
|
||||
|
||||
void ShapeInfo::setConvexHulls(const QVector<QVector<glm::vec3>>& points) {
|
||||
if (points.size() == 1) {
|
||||
_type = SHAPE_TYPE_CONVEX_HULL;
|
||||
} else {
|
||||
_type = SHAPE_TYPE_COMPOUND;
|
||||
}
|
||||
_points = points;
|
||||
_type = (_points.size() > 0) ? SHAPE_TYPE_COMPOUND : SHAPE_TYPE_NONE;
|
||||
_doubleHashKey.clear();
|
||||
}
|
||||
|
||||
|
@ -95,6 +85,14 @@ void ShapeInfo::setCapsuleY(float radius, float halfHeight) {
|
|||
_doubleHashKey.clear();
|
||||
}
|
||||
|
||||
uint32_t ShapeInfo::getNumSubShapes() const {
|
||||
if (_type == SHAPE_TYPE_NONE) {
|
||||
return 0;
|
||||
} else if (_type == SHAPE_TYPE_COMPOUND) {
|
||||
return _points.size();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
float ShapeInfo::computeVolume() const {
|
||||
const float DEFAULT_VOLUME = 1.0f;
|
||||
float volume = DEFAULT_VOLUME;
|
||||
|
|
|
@ -24,7 +24,6 @@ enum ShapeType {
|
|||
SHAPE_TYPE_BOX,
|
||||
SHAPE_TYPE_SPHERE,
|
||||
SHAPE_TYPE_ELLIPSOID,
|
||||
SHAPE_TYPE_CONVEX_HULL,
|
||||
SHAPE_TYPE_PLANE,
|
||||
SHAPE_TYPE_COMPOUND,
|
||||
SHAPE_TYPE_CAPSULE_X,
|
||||
|
@ -52,6 +51,7 @@ public:
|
|||
const glm::vec3& getHalfExtents() const { return _halfExtents; }
|
||||
|
||||
const QVector<QVector<glm::vec3>>& getPoints() const { return _points; }
|
||||
uint32_t getNumSubShapes() const;
|
||||
|
||||
void clearPoints () { _points.clear(); }
|
||||
void appendToPoints (const QVector<glm::vec3>& newPoints) { _points << newPoints; }
|
||||
|
|
|
@ -147,9 +147,7 @@ void ShapeInfoTests::testBoxShape() {
|
|||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: NULL Box shape" << std::endl;
|
||||
}
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
@ -172,9 +170,7 @@ void ShapeInfoTests::testSphereShape() {
|
|||
|
||||
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info);
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
@ -198,9 +194,7 @@ void ShapeInfoTests::testCylinderShape() {
|
|||
|
||||
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info);
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
@ -225,9 +219,7 @@ void ShapeInfoTests::testCapsuleShape() {
|
|||
|
||||
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info);
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
|
|
@ -187,9 +187,7 @@ void ShapeManagerTests::addBoxShape() {
|
|||
ShapeManager shapeManager;
|
||||
btCollisionShape* shape = shapeManager.getShape(info);
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
@ -205,9 +203,7 @@ void ShapeManagerTests::addSphereShape() {
|
|||
ShapeManager shapeManager;
|
||||
btCollisionShape* shape = shapeManager.getShape(info);
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
@ -225,9 +221,7 @@ void ShapeManagerTests::addCylinderShape() {
|
|||
ShapeManager shapeManager;
|
||||
btCollisionShape* shape = shapeManager.getShape(info);
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
@ -246,9 +240,7 @@ void ShapeManagerTests::addCapsuleShape() {
|
|||
ShapeManager shapeManager;
|
||||
btCollisionShape* shape = shapeManager.getShape(info);
|
||||
|
||||
ShapeInfo otherInfo;
|
||||
ShapeInfoUtil::collectInfoFromShape(shape, otherInfo);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
|
|
Loading…
Reference in a new issue