History

make RenderablePolyVoxEntityItem::setSphere affect any voxel the sphere touches rather than just the ones whose center the sphere touches

Seth Alves committed 9 years ago

Commit df875ab1 parent 048da6e3 files · +58 −8Browse files

Showing the changes to libraries/shared/src/AABox.cpp (1 of 3 files). Show all

Unified · Split

libraries/shared/src/AABox.cpp+26−0
@@ -436,6 +436,32 @@ glm::vec3 AABox::getClosestPointOnFace(const glm::vec4& origin, const glm::vec4& · 435 unmodified lines
436 return getClosestPointOnFace(glm::vec3(origin), face);436 return getClosestPointOnFace(glm::vec3(origin), face);
437}437}
438 438
439bool AABox::touchesAAEllipsoid(const glm::vec3& center, glm::vec3 radials) const {
440 if (_corner.x - radials.x > center.x ||
441 _corner.y - radials.y > center.y ||
442 _corner.z - radials.z > center.z ||
443 _corner.x + _scale.x + radials.x < center.x ||
444 _corner.y + _scale.y + radials.y < center.y ||
445 _corner.z + _scale.z + radials.z < center.z) {
446 return false;
447 }
448
449 for (int i = 0; i < FACE_COUNT; i++) {
450 glm::vec3 closest = getClosestPointOnFace(center, (BoxFace)i) - center;
451 float x = closest.x;
452 float y = closest.y;
453 float z = closest.z;
454 float a = radials.x;
455 float b = radials.y;
456 float c = radials.z;
457 if (x*x/(a*a) + y*y/(b*b) + z*z/(c*c) < 1.0f) {
458 return true;
459 }
460 }
461 return false;
462}
463
464
439glm::vec4 AABox::getPlane(BoxFace face) const {465glm::vec4 AABox::getPlane(BoxFace face) const {
440 switch (face) {466 switch (face) {
441 case MIN_X_FACE: return glm::vec4(-1.0f, 0.0f, 0.0f, _corner.x);467 case MIN_X_FACE: return glm::vec4(-1.0f, 0.0f, 0.0f, _corner.x);