OSG_BASE_DLLMAPPING void extend(SphereVolume &srcVol, const CylinderVolume &vol) { Pnt3f min, max, min1, max1, min2, max2, c; Real32 r; if((!srcVol.isValid () && !srcVol.isEmpty()) || srcVol.isInfinite() || srcVol.isStatic () ) { return; } if(!vol.isValid()) return; if(srcVol.isEmpty()) { if(vol.isEmpty()) { return; } else { vol.getBounds(min, max); vol.getCenter(c); r = (min - c).length(); srcVol.setValue(c, r); return; } } else if(vol.isEmpty()) { return; } srcVol.getBounds(min, max); vol .getBounds(min1, max1); min2 = Pnt3f(osgMin(min.x(), min1.x()), osgMin(min.y(), min1.y()), osgMin(min.z(), min1.z())); max2 = Pnt3f(osgMax(max.x(), max1.x()), osgMax(max.y(), max1.y()), osgMax(max.z(), max1.z())); c = Pnt3f((min2.x() + max2.x()) * 0.5f, (min2.y() + max2.y()) * 0.5f, (min2.z() + max2.z()) * 0.5f); r = ((max2 - min2).length()) * 0.5f; srcVol.setValue(c, r); return; }
OSG_BASE_DLLMAPPING void extend(SphereVolume &srcVol, const Volume &vol) { const Volume *v = &vol; const SphereVolume *sphere; #ifndef OSG_2_PREP const DynamicVolume *dynamic = dynamic_cast<const DynamicVolume *>(v); if(dynamic) { v = &(dynamic->getInstance()); } #endif if((sphere = dynamic_cast<const SphereVolume *>(v)) != NULL) { OSG::extend(srcVol, *sphere); } else { SphereVolume localSphere; Pnt3f min, max, c; Real32 r; v->getBounds(min, max); c = Pnt3f((min.x() + max.x()) * 0.5f, (min.y() + max.y()) * 0.5f, (min.z() + max.z()) * 0.5f); r = ((max - min).length()) * 0.5f; localSphere.setValue(c, r); OSG::extend(srcVol, localSphere); } return; }
OSG_BASE_DLLMAPPING void extend(SphereVolume &srcVol, const BoxVolume &vol) { Pnt3f min, max, min1, max1, c; Real32 r; BoxVolume vol1; vol.getBounds(min, max); if((!srcVol.isValid () && !srcVol.isEmpty()) || srcVol.isInfinite() || srcVol.isStatic () ) { return; } if(!vol.isValid()) return; if(srcVol.isEmpty()) { if(vol.isEmpty()) { return; } else { c = Pnt3f((min.x() + max.x()) * 0.5f, (min.y() + max.y()) * 0.5f, (min.z() + max.z()) * 0.5f); r = ((max - min).length()) / 2; srcVol.setValue(c, r); return; } } else if(vol.isEmpty()) { return; } srcVol.getBounds(min1, max1); vol1.setBounds(osgMin(min.x(), min1.x()), osgMin(min.y(), min1.y()), osgMin(min.z(), min1.z()), osgMax(max.x(), max1.x()), osgMax(max.y(), max1.y()), osgMax(max.z(), max1.z())); vol1.getBounds(min, max); c = Pnt3f((min.x() + max.x()) * 0.5f, (min.y() + max.y()) * 0.5f, (min.z() + max.z()) * 0.5f); r = ((max - min).length()) / 2; srcVol.setValue(c, r); return; }