case ZAxis:
aDist = fabs(aBounds[5] - aBounds[4]);
}
- aDist = aDist*getDistance();
+
+ float dx = fabs(aBounds[1] - aBounds[0]);
+ float dy = fabs(aBounds[3] - aBounds[2]);
+ float dz = fabs(aBounds[5] - aBounds[4]);
+ float max = (dx > dy) ? dx : dy;
+ max = (dz > max) ? dz : max;
+ max /= 100.0;
+
+ if (aDist < max) {
+ // set base distance between centers of bounding boxes
+ // to minimal (but big enough) size of current bounding box
+ if (dx < max) dx = FLT_MAX;
+ if (dy < max) dy = FLT_MAX;
+ if (dz < max) dz = FLT_MAX;
+
+ aDist = (dx < dy) ? dx : dy;
+ aDist = (dz < aDist) ? dz : aDist;
+ }
+ aDist = aDist * getDistance();
for (int i = 0; i < myAnimator->getNbFields(); i++) {
myAnimator->getFieldData(i).myOffset[0] = 0;
myAnimator->getFieldData(i).myOffset[1] = 0;
float aDist = 0;
float aShift = 0;
float aPrevDist = 0;
+ float aPrevShift = 0;
// bool aInit = true;
int i;
QMap<VISU::Prs3d_i*, int>::Iterator it;
float aOffset[3];
aOffset[0] = aOffset[1] = aOffset[2] = 0;
- aShift = (i == 0)? 0 : aShift + (aDist + aPrevDist) * getDistance() / 2;
+ if (i > 0) {
+ float aCCDist = (aDist + aPrevDist) / 2.0;
+
+ float dx = fabs(aBounds[1] - aBounds[0]);
+ float dy = fabs(aBounds[3] - aBounds[2]);
+ float dz = fabs(aBounds[5] - aBounds[4]);
+ float max = (dx > dy) ? dx : dy;
+ max = (dz > max) ? dz : max;
+ max /= 100.0;
+
+ if (aCCDist < max) {
+ // set base distance between centers of bounding boxes
+ // to minimal (but big enough) size of current bounding box
+ if (dx < max) dx = FLT_MAX;
+ if (dy < max) dy = FLT_MAX;
+ if (dz < max) dz = FLT_MAX;
+
+ aCCDist = (dx < dy) ? dx : dy;
+ aCCDist = (dz < aCCDist) ? dz : aCCDist;
+ }
+
+ //-------------------------------->
+ // aShift
+ // aDist / 2
+ // <-->
+ // .--------------. .------.
+ //----------->| | | |
+ // aPrevShift '--------------' '------'
+ // <------>
+ // aPrevDist / 2
+ //
+ // <--------------->
+ // (aDist + aPrevDist) * getDistance() / 2
+
+ aShift = aPrevShift + aPrevDist/2.0 + aCCDist*getDistance() - aDist/2.0;
+ }
aOffset[aAxis] = aShift;
aActor->SetPosition(aOffset);
if (mySaveChk)
if (mySaveChk->isChecked())
aPrs->SetOffset(aOffset);
+
aPrevDist = aDist;
+ aPrevShift = aShift;
}
}
}