Make requested style changes to code.

This commit is contained in:
rick@ghostpunch.com 2017-08-09 04:37:47 -04:00
parent a730da5299
commit cc69853ff1

View file

@ -96,7 +96,7 @@ bool PolyLineEntityItem::appendPoint(const glm::vec3& point) {
_points << point;
_pointsChanged = true;
calculateScaleAndRegistrationPoint();
calculateScaleAndRegistrationPoint();
return true;
}
@ -142,7 +142,7 @@ bool PolyLineEntityItem::setLinePoints(const QVector<glm::vec3>& points) {
_points = points;
calculateScaleAndRegistrationPoint();
calculateScaleAndRegistrationPoint();
result = true;
});
@ -151,37 +151,37 @@ bool PolyLineEntityItem::setLinePoints(const QVector<glm::vec3>& points) {
}
void PolyLineEntityItem::calculateScaleAndRegistrationPoint() {
glm::vec3 high(0.0f, 0.0f, 0.0f);
glm::vec3 low(0.0f, 0.0f, 0.0f);
for (int i = 0; i < _points.size(); i++) {
glm::vec3 point = _points.at(i);
glm::vec3 high(0.0f, 0.0f, 0.0f);
glm::vec3 low(0.0f, 0.0f, 0.0f);
for (int i = 0; i < _points.size(); i++) {
glm::vec3 point = _points.at(i);
if (point.x > high.x){
high.x = point.x;
} else if (point.x < low.x) {
low.x = point.x;
}
if (point.x > high.x) {
high.x = point.x;
} else if (point.x < low.x) {
low.x = point.x;
}
if (point.y > high.y){
high.y = point.y;
} else if (point.y < low.y) {
low.y = point.y;
}
if (point.y > high.y) {
high.y = point.y;
} else if (point.y < low.y) {
low.y = point.y;
}
if (point.z > high.z){
high.z = point.z;
} else if (point.z < low.z) {
low.z = point.z;
}
}
const float EPSILON = 0.0001f;
if (_points.size() > 1) {
// if all the points in the Polyline are at the same place in space, use default dimension settings
if ((low - high).length() < EPSILON) {
SpatiallyNestable::setScale(glm::vec3(1.0f, 1.0f, 1.0f));
EntityItem::setRegistrationPoint(glm::vec3(0.0f, 0.0f, 0.0f));
return;
}
if (point.z > high.z) {
high.z = point.z;
} else if (point.z < low.z) {
low.z = point.z;
}
}
const float EPSILON = 0.0001f;
if (_points.size() > 1) {
// if all the points in the Polyline are at the same place in space, use default dimension settings
if ((low - high).length() < EPSILON) {
SpatiallyNestable::setScale(glm::vec3(1.0f, 1.0f, 1.0f));
EntityItem::setRegistrationPoint(glm::vec3(0.5f));
return;
}
// Find the max width of the strokes so we can account for that in the size of the bounding box
float maxWidth = 0.0f;
@ -192,24 +192,24 @@ void PolyLineEntityItem::calculateScaleAndRegistrationPoint() {
}
}
glm::vec3 result;
glm::vec3 result;
float halfLineWidth = (maxWidth > 0.0f) ? maxWidth * 0.5f : 0.0f;
result.x = fabsf(high.x) + fabsf(low.x) + halfLineWidth;
result.y = fabsf(high.y) + fabsf(low.y) + halfLineWidth;
result.z = fabsf(high.z) + fabsf(low.z) + halfLineWidth;
SpatiallyNestable::setScale(result);
SpatiallyNestable::setScale(result);
// Center the poly line in the bounding box
glm::vec3 point = _points.at(0);
glm::vec3 startPointInScaleSpace = point - low;
glm::vec3 point = _points.at(0);
glm::vec3 startPointInScaleSpace = point - low;
startPointInScaleSpace += glm::vec3(halfLineWidth * 0.5f);
glm::vec3 newRegistrationPoint = startPointInScaleSpace / result;
EntityItem::setRegistrationPoint(newRegistrationPoint);
} else {
// if Polyline has only one or fewer points, use default dimension settings
SpatiallyNestable::setScale(glm::vec3(1.0f, 1.0f, 1.0f));
EntityItem::setRegistrationPoint(glm::vec3(0.0f, 0.0f, 0.0f));
}
glm::vec3 newRegistrationPoint = startPointInScaleSpace / result;
EntityItem::setRegistrationPoint(newRegistrationPoint);
} else {
// if Polyline has only one or fewer points, use default dimension settings
SpatiallyNestable::setScale(glm::vec3(1.0f, 1.0f, 1.0f));
EntityItem::setRegistrationPoint(glm::vec3(0.5f));
}
}
int PolyLineEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,