mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 09:33:29 +02:00
removing SHAPE_TYPE_CONVEX_HULL from entities lib
This commit is contained in:
parent
7da1c51877
commit
5b81b5b11b
5 changed files with 49 additions and 56 deletions
|
@ -274,54 +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 (!_model) {
|
||||
return false; // hmm...
|
||||
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->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 (_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();
|
||||
|
||||
|
@ -415,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;
|
||||
|
|
Loading…
Reference in a new issue