+void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
+ /*if ( !m_pivotChanged || m_pivot_moving ) {
+ return;
+ }*/
+ //m_pivotChanged = false;
+
+ if ( !nothingSelected() && ( m_manipulator_mode == eTranslate || m_manipulator_mode == eRotate || m_manipulator_mode == eScale ) ) {
+ AABB bounds;
+ if ( Mode() == eComponent ) {
+ Scene_BoundsSelectedComponent( GlobalSceneGraph(), bounds );
+ }
+ else
+ {
+ Scene_BoundsSelected( GlobalSceneGraph(), bounds );
+ }
+ //globalOutputStream() << point << "\n";
+ const float gridsize = GetSnapGridSize();
+ //const float bbox_epsilon = gridsize / 4.0;
+
+ for( std::size_t i = 0; i < 3; i++ ){
+ if( point[i] < 900000 ){
+ float bestsnapDist = fabs( bounds.origin[i] - point[i] );
+ float bestsnapTo = bounds.origin[i];
+ float othersnapDist = fabs( bounds.origin[i] + bounds.extents[i] - point[i] );
+ if( othersnapDist < bestsnapDist ){
+ bestsnapDist = othersnapDist;
+ bestsnapTo = bounds.origin[i] + bounds.extents[i];
+ }
+ othersnapDist = fabs( bounds.origin[i] - bounds.extents[i] - point[i] );
+ if( othersnapDist < bestsnapDist ){
+ bestsnapDist = othersnapDist;
+ bestsnapTo = bounds.origin[i] - bounds.extents[i];
+ }
+ othersnapDist = fabs( float_snapped( point[i], gridsize ) - point[i] );
+ if( othersnapDist < bestsnapDist ){
+ bestsnapDist = othersnapDist;
+ bestsnapTo = float_snapped( point[i], gridsize );
+ }
+ point[i] = bestsnapTo;
+
+/* if( float_equal_epsilon( point[i], bestsnapTo, bbox_epsilon ) ){
+ point[i] = bestsnapTo;
+ }
+ else{
+ point[i] = float_snapped( point[i], gridsize );
+ }
+ */
+ m_pivot2world[i + 12] = point[i]; //m_pivot2world.tx() .ty() .tz()
+ }
+ }
+
+ switch ( m_manipulator_mode )
+ {
+ case eTranslate:
+ break;
+ case eRotate:
+ if ( Mode() == eComponent ) {
+ matrix4_assign_rotation_for_pivot( m_pivot2world, m_component_selection.back() );
+ }
+ else
+ {
+ matrix4_assign_rotation_for_pivot( m_pivot2world, m_selection.back() );
+ }
+ break;
+ case eScale:
+ if ( Mode() == eComponent ) {
+ matrix4_assign_rotation_for_pivot( m_pivot2world, m_component_selection.back() );
+ }
+ else
+ {
+ matrix4_assign_rotation_for_pivot( m_pivot2world, m_selection.back() );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ m_pivotIsCustom = true;
+}
+
+void RadiantSelectionSystem::getSelectionAABB( AABB& bounds ) const {
+ if ( !nothingSelected() ) {
+ if ( Mode() == eComponent ) {
+ Scene_BoundsSelectedComponent( GlobalSceneGraph(), bounds );
+ }
+ else
+ {
+ Scene_BoundsSelected( GlobalSceneGraph(), bounds );
+ }
+ }
+}
+
+void GetSelectionAABB( AABB& bounds ){
+ getSelectionSystem().getSelectionAABB( bounds );
+}
+
+const Matrix4& ssGetPivot2World(){
+ return getSelectionSystem().GetPivot2World();
+}
+