mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:27:48 +02:00
revert compound hull shape generation
This commit is contained in:
parent
702e83ba6a
commit
e88b264864
1 changed files with 5 additions and 20 deletions
|
@ -618,7 +618,6 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
// to find one actual "mesh" (with one or more meshParts in it), but we loop over the meshes, just in case.
|
// to find one actual "mesh" (with one or more meshParts in it), but we loop over the meshes, just in case.
|
||||||
const uint32_t TRIANGLE_STRIDE = 3;
|
const uint32_t TRIANGLE_STRIDE = 3;
|
||||||
const uint32_t QUAD_STRIDE = 4;
|
const uint32_t QUAD_STRIDE = 4;
|
||||||
Extents extents;
|
|
||||||
foreach (const FBXMesh& mesh, collisionGeometry.meshes) {
|
foreach (const FBXMesh& mesh, collisionGeometry.meshes) {
|
||||||
// each meshPart is a convex hull
|
// each meshPart is a convex hull
|
||||||
foreach (const FBXMeshPart &meshPart, mesh.parts) {
|
foreach (const FBXMeshPart &meshPart, mesh.parts) {
|
||||||
|
@ -632,18 +631,14 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
glm::vec3 p0 = mesh.vertices[meshPart.triangleIndices[j]];
|
glm::vec3 p0 = mesh.vertices[meshPart.triangleIndices[j]];
|
||||||
glm::vec3 p1 = mesh.vertices[meshPart.triangleIndices[j + 1]];
|
glm::vec3 p1 = mesh.vertices[meshPart.triangleIndices[j + 1]];
|
||||||
glm::vec3 p2 = mesh.vertices[meshPart.triangleIndices[j + 2]];
|
glm::vec3 p2 = mesh.vertices[meshPart.triangleIndices[j + 2]];
|
||||||
|
|
||||||
if (!pointsInPart.contains(p0)) {
|
if (!pointsInPart.contains(p0)) {
|
||||||
pointsInPart << p0;
|
pointsInPart << p0;
|
||||||
extents.addPoint(p0);
|
|
||||||
}
|
}
|
||||||
if (!pointsInPart.contains(p1)) {
|
if (!pointsInPart.contains(p1)) {
|
||||||
pointsInPart << p1;
|
pointsInPart << p1;
|
||||||
extents.addPoint(p1);
|
|
||||||
}
|
}
|
||||||
if (!pointsInPart.contains(p2)) {
|
if (!pointsInPart.contains(p2)) {
|
||||||
pointsInPart << p2;
|
pointsInPart << p2;
|
||||||
extents.addPoint(p2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,19 +652,15 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
glm::vec3 p3 = mesh.vertices[meshPart.quadIndices[j + 3]];
|
glm::vec3 p3 = mesh.vertices[meshPart.quadIndices[j + 3]];
|
||||||
if (!pointsInPart.contains(p0)) {
|
if (!pointsInPart.contains(p0)) {
|
||||||
pointsInPart << p0;
|
pointsInPart << p0;
|
||||||
extents.addPoint(p0);
|
|
||||||
}
|
}
|
||||||
if (!pointsInPart.contains(p1)) {
|
if (!pointsInPart.contains(p1)) {
|
||||||
pointsInPart << p1;
|
pointsInPart << p1;
|
||||||
extents.addPoint(p1);
|
|
||||||
}
|
}
|
||||||
if (!pointsInPart.contains(p2)) {
|
if (!pointsInPart.contains(p2)) {
|
||||||
pointsInPart << p2;
|
pointsInPart << p2;
|
||||||
extents.addPoint(p2);
|
|
||||||
}
|
}
|
||||||
if (!pointsInPart.contains(p3)) {
|
if (!pointsInPart.contains(p3)) {
|
||||||
pointsInPart << p3;
|
pointsInPart << p3;
|
||||||
extents.addPoint(p3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,29 +673,23 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 extentsSize = extents.size();
|
|
||||||
glm::vec3 scaleToFit = dimensions / extentsSize;
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
if (extentsSize[i] < 1.0e-6f) {
|
|
||||||
scaleToFit[i] = 1.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We expect that the collision model will have the same units and will be displaced
|
// We expect that the collision model will have the same units and will be displaced
|
||||||
// from its origin in the same way the visual model is. The visual model has
|
// from its origin in the same way the visual model is. The visual model has
|
||||||
// been centered and probably scaled. We take the scaling and offset which were applied
|
// been centered and probably scaled. We take the scaling and offset which were applied
|
||||||
// to the visual model and apply them to the collision model (without regard for the
|
// to the visual model and apply them to the collision model (without regard for the
|
||||||
// collision model's extents).
|
// collision model's extents).
|
||||||
|
|
||||||
|
glm::vec3 scaleToFit = dimensions / _model->getFBXGeometry().getUnscaledMeshExtents().size();
|
||||||
// multiply each point by scale before handing the point-set off to the physics engine.
|
// multiply each point by scale before handing the point-set off to the physics engine.
|
||||||
// also determine the extents of the collision model.
|
// also determine the extents of the collision model.
|
||||||
glm::vec3 scaledModelOffset = _model->getOffset() * _model->getScale();
|
|
||||||
for (int i = 0; i < pointCollection.size(); i++) {
|
for (int i = 0; i < pointCollection.size(); i++) {
|
||||||
for (int j = 0; j < pointCollection[i].size(); j++) {
|
for (int j = 0; j < pointCollection[i].size(); j++) {
|
||||||
pointCollection[i][j] = (pointCollection[i][j] * scaleToFit) + scaledModelOffset;
|
// compensate for registration
|
||||||
|
pointCollection[i][j] += _model->getOffset();
|
||||||
|
// scale so the collision points match the model points
|
||||||
|
pointCollection[i][j] *= scaleToFit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.setParams(type, dimensions, _compoundShapeURL);
|
info.setParams(type, dimensions, _compoundShapeURL);
|
||||||
} else if (type == SHAPE_TYPE_STATIC_MESH) {
|
} else if (type == SHAPE_TYPE_STATIC_MESH) {
|
||||||
// compute meshPart local transforms
|
// compute meshPart local transforms
|
||||||
|
|
Loading…
Reference in a new issue