mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:56:43 +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,32 +274,19 @@ 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() {
|
bool RenderableModelEntityItem::isReadyToComputeShape() {
|
||||||
|
ShapeType type = getShapeType();
|
||||||
|
if (type == SHAPE_TYPE_COMPOUND) {
|
||||||
|
|
||||||
if (!_model) {
|
if (!_model) {
|
||||||
return false; // hmm...
|
return false; // hmm...
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_model->getCollisionURL().isEmpty()) {
|
assert(!_model->getCollisionURL().isEmpty());
|
||||||
// no collision-model url, so we're ready to compute a shape (of type None).
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (_model->getURL().isEmpty()) {
|
if (_model->getURL().isEmpty()) {
|
||||||
// we need a render geometry with a scale to proceed, so give up.
|
// we need a render geometry with a scale to proceed, so give up.
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = _model->getCollisionGeometry();
|
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = _model->getCollisionGeometry();
|
||||||
|
@ -312,16 +299,25 @@ bool RenderableModelEntityItem::isReadyToComputeShape() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the model is still being downloaded.
|
// the model is still being downloaded.
|
||||||
|
std::cout << "adebug still being downloaded" << std::endl; // adebug
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
if (_model->getCollisionURL().isEmpty() || _model->getURL().isEmpty()) {
|
ShapeType type = getShapeType();
|
||||||
info.setParams(getShapeType(), 0.5f * getDimensions());
|
if (type != SHAPE_TYPE_COMPOUND) {
|
||||||
|
ModelEntityItem::computeShapeInfo(info);
|
||||||
|
info.setParams(_shapeType, 0.5f * getDimensions());
|
||||||
} else {
|
} else {
|
||||||
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = _model->getCollisionGeometry();
|
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 QSharedPointer<NetworkGeometry> renderNetworkGeometry = _model->getGeometry();
|
||||||
const FBXGeometry& renderGeometry = renderNetworkGeometry->getFBXGeometry();
|
const FBXGeometry& renderGeometry = renderNetworkGeometry->getFBXGeometry();
|
||||||
|
|
||||||
|
@ -415,18 +411,8 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 collisionModelDimensions = box.getDimensions();
|
glm::vec3 collisionModelDimensions = box.getDimensions();
|
||||||
info.setParams(getShapeType(), collisionModelDimensions, _collisionModelURL);
|
info.setParams(_shapeType, collisionModelDimensions, _collisionModelURL);
|
||||||
info.setConvexHulls(_points);
|
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;
|
bool needsToCallUpdate() const;
|
||||||
|
|
||||||
virtual void setCollisionModelURL(const QString& url);
|
virtual void setCollisionModelURL(const QString& url);
|
||||||
virtual bool hasCollisionModel() const;
|
|
||||||
virtual const QString& getCollisionModelURL() const;
|
|
||||||
|
|
||||||
bool isReadyToComputeShape();
|
bool isReadyToComputeShape();
|
||||||
void computeShapeInfo(ShapeInfo& info);
|
void computeShapeInfo(ShapeInfo& info);
|
||||||
ShapeType getShapeType() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void remapTextures();
|
void remapTextures();
|
||||||
|
|
|
@ -192,7 +192,7 @@ void buildStringToShapeTypeLookup() {
|
||||||
stringToShapeTypeLookup["box"] = SHAPE_TYPE_BOX;
|
stringToShapeTypeLookup["box"] = SHAPE_TYPE_BOX;
|
||||||
stringToShapeTypeLookup["sphere"] = SHAPE_TYPE_SPHERE;
|
stringToShapeTypeLookup["sphere"] = SHAPE_TYPE_SPHERE;
|
||||||
stringToShapeTypeLookup["ellipsoid"] = SHAPE_TYPE_ELLIPSOID;
|
stringToShapeTypeLookup["ellipsoid"] = SHAPE_TYPE_ELLIPSOID;
|
||||||
stringToShapeTypeLookup["convex-hull"] = SHAPE_TYPE_CONVEX_HULL;
|
stringToShapeTypeLookup["convex-hull"] = SHAPE_TYPE_COMPOUND;
|
||||||
stringToShapeTypeLookup["plane"] = SHAPE_TYPE_PLANE;
|
stringToShapeTypeLookup["plane"] = SHAPE_TYPE_PLANE;
|
||||||
stringToShapeTypeLookup["compound"] = SHAPE_TYPE_COMPOUND;
|
stringToShapeTypeLookup["compound"] = SHAPE_TYPE_COMPOUND;
|
||||||
stringToShapeTypeLookup["capsule-x"] = SHAPE_TYPE_CAPSULE_X;
|
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) {
|
void ModelEntityItem::setCollisionModelURL(const QString& url) {
|
||||||
if (_collisionModelURL != url) {
|
if (_collisionModelURL != url) {
|
||||||
_collisionModelURL = url;
|
_collisionModelURL = url;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
virtual void debugDump() const;
|
virtual void debugDump() const;
|
||||||
|
|
||||||
void updateShapeType(ShapeType type);
|
void updateShapeType(ShapeType type);
|
||||||
virtual ShapeType getShapeType() const { return _shapeType; }
|
virtual ShapeType getShapeType() const;
|
||||||
|
|
||||||
// TODO: Move these to subclasses, or other appropriate abstraction
|
// TODO: Move these to subclasses, or other appropriate abstraction
|
||||||
// getters/setters applicable to models and particles
|
// getters/setters applicable to models and particles
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
const QString& getModelURL() const { return _modelURL; }
|
const QString& getModelURL() const { return _modelURL; }
|
||||||
|
|
||||||
static const QString DEFAULT_COLLISION_MODEL_URL;
|
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(); }
|
bool hasAnimation() const { return !_animationURL.isEmpty(); }
|
||||||
static const QString DEFAULT_ANIMATION_URL;
|
static const QString DEFAULT_ANIMATION_URL;
|
||||||
|
|
Loading…
Reference in a new issue