Merge pull request #14827 from luiscuenca/FixShapeInfoAssertion

Case 14722: Fix assertion when trying to create multisphere shapeInfo with empty data (80.0/master)
This commit is contained in:
Anthony Thibault 2019-02-08 15:10:44 -08:00 committed by GitHub
commit e6cdfe3377
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View file

@ -1736,6 +1736,7 @@ void Avatar::computeShapeInfo(ShapeInfo& shapeInfo) {
void Avatar::computeDetailedShapeInfo(ShapeInfo& shapeInfo, int jointIndex) { void Avatar::computeDetailedShapeInfo(ShapeInfo& shapeInfo, int jointIndex) {
if (jointIndex > -1 && jointIndex < (int)_multiSphereShapes.size()) { if (jointIndex > -1 && jointIndex < (int)_multiSphereShapes.size()) {
auto& data = _multiSphereShapes[jointIndex].getSpheresData(); auto& data = _multiSphereShapes[jointIndex].getSpheresData();
if (data.size() > 0) {
std::vector<glm::vec3> positions; std::vector<glm::vec3> positions;
std::vector<btScalar> radiuses; std::vector<btScalar> radiuses;
positions.reserve(data.size()); positions.reserve(data.size());
@ -1747,6 +1748,7 @@ void Avatar::computeDetailedShapeInfo(ShapeInfo& shapeInfo, int jointIndex) {
shapeInfo.setMultiSphere(positions, radiuses); shapeInfo.setMultiSphere(positions, radiuses);
} }
} }
}
void Avatar::getCapsule(glm::vec3& start, glm::vec3& end, float& radius) { void Avatar::getCapsule(glm::vec3& start, glm::vec3& end, float& radius) {
ShapeInfo shapeInfo; ShapeInfo shapeInfo;

View file

@ -152,7 +152,8 @@ void ShapeInfo::setSphere(float radius) {
void ShapeInfo::setMultiSphere(const std::vector<glm::vec3>& centers, const std::vector<float>& radiuses) { void ShapeInfo::setMultiSphere(const std::vector<glm::vec3>& centers, const std::vector<float>& radiuses) {
_url = ""; _url = "";
_type = SHAPE_TYPE_MULTISPHERE; _type = SHAPE_TYPE_MULTISPHERE;
assert(centers.size() == radiuses.size() && centers.size() > 0); assert(centers.size() == radiuses.size());
assert(centers.size() > 0);
for (size_t i = 0; i < centers.size(); i++) { for (size_t i = 0; i < centers.size(); i++) {
SphereData sphere = SphereData(centers[i], radiuses[i]); SphereData sphere = SphereData(centers[i], radiuses[i]);
_sphereCollection.push_back(sphere); _sphereCollection.push_back(sphere);