mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
enforce dimensions of Circles and Quads
This commit is contained in:
parent
901e145712
commit
474609dabf
2 changed files with 27 additions and 19 deletions
|
@ -104,6 +104,14 @@ void ShapeEntityItem::setShape(const entity::Shape& shape) {
|
||||||
case entity::Shape::Sphere:
|
case entity::Shape::Sphere:
|
||||||
_type = EntityTypes::Sphere;
|
_type = EntityTypes::Sphere;
|
||||||
break;
|
break;
|
||||||
|
case entity::Shape::Circle:
|
||||||
|
// Circle is implicitly flat so we enforce flat dimensions
|
||||||
|
setDimensions(getDimensions());
|
||||||
|
break;
|
||||||
|
case entity::Shape::Quad:
|
||||||
|
// Quad is implicitly flat so we enforce flat dimensions
|
||||||
|
setDimensions(getDimensions());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
_type = EntityTypes::Shape;
|
_type = EntityTypes::Shape;
|
||||||
break;
|
break;
|
||||||
|
@ -196,6 +204,18 @@ void ShapeEntityItem::setColor(const QColor& value) {
|
||||||
setAlpha(value.alpha());
|
setAlpha(value.alpha());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShapeEntityItem::setDimensions(const glm::vec3& value) {
|
||||||
|
const float MAX_FLAT_DIMENSION = 0.0001f;
|
||||||
|
if ((_shape == entity::Shape::Circle || _shape == entity::Shape::Quad) && value.y > MAX_FLAT_DIMENSION) {
|
||||||
|
// enforce flatness in Y
|
||||||
|
glm::vec3 newDimensions = value;
|
||||||
|
newDimensions.y = MAX_FLAT_DIMENSION;
|
||||||
|
EntityItem::setDimensions(newDimensions);
|
||||||
|
} else {
|
||||||
|
EntityItem::setDimensions(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ShapeEntityItem::supportsDetailedRayIntersection() const {
|
bool ShapeEntityItem::supportsDetailedRayIntersection() const {
|
||||||
return _shape == entity::Sphere;
|
return _shape == entity::Sphere;
|
||||||
}
|
}
|
||||||
|
@ -249,13 +269,8 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
const glm::vec3 entityDimensions = getDimensions();
|
const glm::vec3 entityDimensions = getDimensions();
|
||||||
|
|
||||||
switch (_shape){
|
switch (_shape){
|
||||||
case entity::Shape::Quad: {
|
case entity::Shape::Quad:
|
||||||
// Not in GeometryCache::buildShapes, unsupported.
|
// Quads collide like flat Cubes
|
||||||
_collisionShapeType = SHAPE_TYPE_ELLIPSOID;
|
|
||||||
//TODO WL21389: Add a SHAPE_TYPE_QUAD ShapeType and treat
|
|
||||||
// as a special box (later if desired support)
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case entity::Shape::Cube: {
|
case entity::Shape::Cube: {
|
||||||
_collisionShapeType = SHAPE_TYPE_BOX;
|
_collisionShapeType = SHAPE_TYPE_BOX;
|
||||||
}
|
}
|
||||||
|
@ -275,19 +290,10 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case entity::Shape::Circle: {
|
case entity::Shape::Circle:
|
||||||
_collisionShapeType = SHAPE_TYPE_CIRCLE;
|
// Circles collide like flat Cylinders
|
||||||
}
|
|
||||||
break;
|
|
||||||
case entity::Shape::Cylinder: {
|
case entity::Shape::Cylinder: {
|
||||||
_collisionShapeType = SHAPE_TYPE_CYLINDER_Y;
|
_collisionShapeType = SHAPE_TYPE_CYLINDER_Y;
|
||||||
// TODO WL21389: determine if rotation is axis-aligned
|
|
||||||
//const Transform::Quat & rot = _transform.getRotation();
|
|
||||||
|
|
||||||
// TODO WL21389: some way to tell apart SHAPE_TYPE_CYLINDER_Y, _X, _Z based on rotation and
|
|
||||||
// hull ( or dimensions, need circular cross section)
|
|
||||||
// Should allow for minor variance along axes?
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case entity::Shape::Cone: {
|
case entity::Shape::Cone: {
|
||||||
|
@ -330,7 +336,7 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
case entity::Shape::Torus: {
|
case entity::Shape::Torus: {
|
||||||
// Not in GeometryCache::buildShapes, unsupported.
|
// Not in GeometryCache::buildShapes, unsupported.
|
||||||
_collisionShapeType = SHAPE_TYPE_ELLIPSOID;
|
_collisionShapeType = SHAPE_TYPE_ELLIPSOID;
|
||||||
//TODO WL21389: SHAPE_TYPE_SIMPLE_HULL and pointCollection (later if desired support)
|
//TODO handle this shape more correctly
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
const rgbColor& getColor() const { return _color; }
|
const rgbColor& getColor() const { return _color; }
|
||||||
void setColor(const rgbColor& value);
|
void setColor(const rgbColor& value);
|
||||||
|
|
||||||
|
void setDimensions(const glm::vec3& value) override;
|
||||||
|
|
||||||
xColor getXColor() const;
|
xColor getXColor() const;
|
||||||
void setColor(const xColor& value);
|
void setColor(const xColor& value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue