mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 20:33:09 +02:00
[WL21389] Set Simulation::DIRTY_SHAPE flag when entity::Shape changes (details below).
* Fixes an issue where ShapeEntityItem's collisionShapeType wasn't updated when its entity::Shape type was changed. * Adds getNameForShapeType static method to ShapeInfo. ** Moves shapeTypeNames[] from EntityItemProperties.cpp to ShapeInfo.cpp * Adds collisionShapeType to ShapeEntityItem::debugDump * Tested creating shapes within the Creation Menu: ** Create Menu -> (Box/Sphere) *** Observe Properties tab auto-focus ** From Properties tab elect alternate shape type from the Shape Dropdown list. NOTE: While this fixes an issue with the collision shape, it doesn't completely resolve the issues seen with the polyhedra or polygonal shapes noticed on RELEASE-7130 rebase. Reviewed-by: Leander Hasty <leander@1stplayable.com> Changes Committed: modified: libraries/entities/src/EntityItemProperties.cpp modified: libraries/entities/src/ShapeEntityItem.cpp modified: libraries/shared/src/ShapeInfo.cpp modified: libraries/shared/src/ShapeInfo.h
This commit is contained in:
parent
7f9ce5a4cd
commit
dbd1a80046
4 changed files with 40 additions and 21 deletions
|
@ -84,28 +84,11 @@ void EntityItemProperties::setLastEdited(quint64 usecTime) {
|
||||||
_lastEdited = usecTime > _created ? usecTime : _created;
|
_lastEdited = usecTime > _created ? usecTime : _created;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* shapeTypeNames[] = {
|
|
||||||
"none",
|
|
||||||
"box",
|
|
||||||
"sphere",
|
|
||||||
"capsule-x",
|
|
||||||
"capsule-y",
|
|
||||||
"capsule-z",
|
|
||||||
"cylinder-x",
|
|
||||||
"cylinder-y",
|
|
||||||
"cylinder-z",
|
|
||||||
"hull",
|
|
||||||
"plane",
|
|
||||||
"compound",
|
|
||||||
"simple-hull",
|
|
||||||
"simple-compound",
|
|
||||||
"static-mesh"
|
|
||||||
};
|
|
||||||
|
|
||||||
QHash<QString, ShapeType> stringToShapeTypeLookup;
|
QHash<QString, ShapeType> stringToShapeTypeLookup;
|
||||||
|
|
||||||
void addShapeType(ShapeType type) {
|
void addShapeType(ShapeType type) {
|
||||||
stringToShapeTypeLookup[shapeTypeNames[type]] = type;
|
stringToShapeTypeLookup[ShapeInfo::getNameForShapeType(type)] = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildStringToShapeTypeLookup() {
|
void buildStringToShapeTypeLookup() {
|
||||||
|
@ -180,9 +163,7 @@ void EntityItemProperties::setCollisionMaskFromString(const QString& maskString)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EntityItemProperties::getShapeTypeAsString() const {
|
QString EntityItemProperties::getShapeTypeAsString() const {
|
||||||
if (_shapeType < sizeof(shapeTypeNames) / sizeof(char *))
|
return ShapeInfo::getNameForShapeType(_shapeType);
|
||||||
return QString(shapeTypeNames[_shapeType]);
|
|
||||||
return QString(shapeTypeNames[SHAPE_TYPE_NONE]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) {
|
void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) {
|
||||||
|
|
|
@ -95,6 +95,7 @@ EntityItemProperties ShapeEntityItem::getProperties(EntityPropertyFlags desiredP
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeEntityItem::setShape(const entity::Shape& shape) {
|
void ShapeEntityItem::setShape(const entity::Shape& shape) {
|
||||||
|
const entity::Shape prevShape = _shape;
|
||||||
_shape = shape;
|
_shape = shape;
|
||||||
switch (_shape) {
|
switch (_shape) {
|
||||||
case entity::Shape::Cube:
|
case entity::Shape::Cube:
|
||||||
|
@ -107,6 +108,11 @@ void ShapeEntityItem::setShape(const entity::Shape& shape) {
|
||||||
_type = EntityTypes::Shape;
|
_type = EntityTypes::Shape;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_shape != prevShape) {
|
||||||
|
// Internally grabs writeLock
|
||||||
|
markDirtyFlags(Simulation::DIRTY_SHAPE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShapeEntityItem::setProperties(const EntityItemProperties& properties) {
|
bool ShapeEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
|
@ -227,6 +233,7 @@ void ShapeEntityItem::debugDump() const {
|
||||||
qCDebug(entities) << "SHAPE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
qCDebug(entities) << "SHAPE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||||
qCDebug(entities) << " name:" << _name;
|
qCDebug(entities) << " name:" << _name;
|
||||||
qCDebug(entities) << " shape:" << stringFromShape(_shape) << " (EnumId: " << _shape << " )";
|
qCDebug(entities) << " shape:" << stringFromShape(_shape) << " (EnumId: " << _shape << " )";
|
||||||
|
qCDebug(entities) << " collisionShapeType:" << ShapeInfo::getNameForShapeType(getShapeType());
|
||||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||||
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
qCDebug(entities) << " position:" << debugTreeVector(getPosition());
|
||||||
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions());
|
||||||
|
|
|
@ -15,9 +15,38 @@
|
||||||
|
|
||||||
#include "NumericalConstants.h" // for MILLIMETERS_PER_METER
|
#include "NumericalConstants.h" // for MILLIMETERS_PER_METER
|
||||||
|
|
||||||
|
// Originally within EntityItemProperties.cpp
|
||||||
|
const char* shapeTypeNames[] = {
|
||||||
|
"none",
|
||||||
|
"box",
|
||||||
|
"sphere",
|
||||||
|
"capsule-x",
|
||||||
|
"capsule-y",
|
||||||
|
"capsule-z",
|
||||||
|
"cylinder-x",
|
||||||
|
"cylinder-y",
|
||||||
|
"cylinder-z",
|
||||||
|
"hull",
|
||||||
|
"plane",
|
||||||
|
"compound",
|
||||||
|
"simple-hull",
|
||||||
|
"simple-compound",
|
||||||
|
"static-mesh"
|
||||||
|
};
|
||||||
|
|
||||||
|
static const size_t SHAPETYPE_NAME_COUNT = (sizeof(shapeTypeNames) / sizeof((shapeTypeNames)[0]));
|
||||||
|
|
||||||
// Bullet doesn't support arbitrarily small shapes
|
// Bullet doesn't support arbitrarily small shapes
|
||||||
const float MIN_HALF_EXTENT = 0.005f; // 0.5 cm
|
const float MIN_HALF_EXTENT = 0.005f; // 0.5 cm
|
||||||
|
|
||||||
|
QString ShapeInfo::getNameForShapeType(ShapeType type) {
|
||||||
|
if (((int)type <= 0) || ((int)type >= SHAPETYPE_NAME_COUNT)) {
|
||||||
|
type = (ShapeType)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shapeTypeNames[(int)type];
|
||||||
|
}
|
||||||
|
|
||||||
void ShapeInfo::clear() {
|
void ShapeInfo::clear() {
|
||||||
_url.clear();
|
_url.clear();
|
||||||
_pointCollection.clear();
|
_pointCollection.clear();
|
||||||
|
|
|
@ -58,6 +58,8 @@ public:
|
||||||
using PointCollection = QVector<PointList>;
|
using PointCollection = QVector<PointList>;
|
||||||
using TriangleIndices = QVector<int32_t>;
|
using TriangleIndices = QVector<int32_t>;
|
||||||
|
|
||||||
|
static QString getNameForShapeType(ShapeType type);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void setParams(ShapeType type, const glm::vec3& halfExtents, QString url="");
|
void setParams(ShapeType type, const glm::vec3& halfExtents, QString url="");
|
||||||
|
|
Loading…
Reference in a new issue