make Scene_BoundsSelected lazily evaluatable
This commit is contained in:
parent
c5f2279f4a
commit
afdf2a76e0
|
|
@ -56,6 +56,8 @@ template<typename Element> class BasicVector4;
|
|||
typedef BasicVector4<float> Vector4;
|
||||
typedef Vector4 Quaternion;
|
||||
|
||||
class AABB;
|
||||
|
||||
typedef Callback1<const Selectable&> SelectionChangeCallback;
|
||||
typedef SignalHandler1<const Selectable&> SelectionChangeHandler;
|
||||
|
||||
|
|
@ -127,6 +129,8 @@ virtual void scaleSelected( const Vector3& scaling, bool snapOrigin = false ) =
|
|||
|
||||
virtual void pivotChanged() const = 0;
|
||||
virtual void setCustomTransformOrigin( const Vector3& origin, const bool set[3] ) const = 0;
|
||||
|
||||
virtual const AABB& getBoundsSelected() const = 0; /* object bounds */
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@
|
|||
#include "patch.h"
|
||||
#include "patchmanip.h"
|
||||
#include "patchdialog.h"
|
||||
#include "selection.h"
|
||||
#include "texwindow.h"
|
||||
#include "gtkmisc.h"
|
||||
#include "mainframe.h"
|
||||
|
|
@ -535,16 +534,13 @@ void Select_SetFlags( const ContentsFlagsValue& flags ){
|
|||
}
|
||||
|
||||
void Select_GetBounds( Vector3& mins, Vector3& maxs ){
|
||||
AABB bounds;
|
||||
Scene_BoundsSelected( GlobalSceneGraph(), bounds );
|
||||
const AABB bounds = GlobalSelectionSystem().getBoundsSelected();
|
||||
maxs = vector3_added( bounds.origin, bounds.extents );
|
||||
mins = vector3_subtracted( bounds.origin, bounds.extents );
|
||||
}
|
||||
|
||||
void Select_GetMid( Vector3& mid ){
|
||||
AABB bounds;
|
||||
Scene_BoundsSelected( GlobalSceneGraph(), bounds );
|
||||
mid = vector3_snapped( bounds.origin );
|
||||
mid = vector3_snapped( GlobalSelectionSystem().getBoundsSelected().origin );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4261,6 +4261,26 @@ void Scene_SelectAll_Component( bool select, SelectionSystem::EComponentMode com
|
|||
GlobalSceneGraph().traverse( select_all_component( select, componentMode ) );
|
||||
}
|
||||
|
||||
void Scene_BoundsSelected( scene::Graph& graph, AABB& bounds );
|
||||
class LazyBounds
|
||||
{
|
||||
AABB m_bounds;
|
||||
bool m_valid;
|
||||
public:
|
||||
LazyBounds() : m_valid( false ){
|
||||
}
|
||||
void setInvalid(){
|
||||
m_valid = false;
|
||||
}
|
||||
const AABB& getBounds(){
|
||||
if( !m_valid ){
|
||||
Scene_BoundsSelected( GlobalSceneGraph(), m_bounds );
|
||||
m_valid = true;
|
||||
}
|
||||
return m_bounds;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// RadiantSelectionSystem
|
||||
class RadiantSelectionSystem :
|
||||
|
|
@ -4274,6 +4294,7 @@ class RadiantSelectionSystem :
|
|||
{
|
||||
mutable Matrix4 m_pivot2world;
|
||||
mutable AABB m_bounds;
|
||||
mutable LazyBounds m_lazy_bounds;
|
||||
Matrix4 m_pivot2world_start;
|
||||
Matrix4 m_manip2pivot_start;
|
||||
Translation m_translation;
|
||||
|
|
@ -4359,6 +4380,7 @@ RadiantSelectionSystem() :
|
|||
}
|
||||
void pivotChanged() const {
|
||||
m_pivotChanged = true;
|
||||
m_lazy_bounds.setInvalid();
|
||||
SceneChangeNotify();
|
||||
}
|
||||
typedef ConstMemberCaller<RadiantSelectionSystem, &RadiantSelectionSystem::pivotChanged> PivotChangedCaller;
|
||||
|
|
@ -4367,6 +4389,10 @@ void pivotChangedSelection( const Selectable& selectable ){
|
|||
}
|
||||
typedef MemberCaller1<RadiantSelectionSystem, const Selectable&, &RadiantSelectionSystem::pivotChangedSelection> PivotChangedSelectionCaller;
|
||||
|
||||
const AABB& getBoundsSelected() const {
|
||||
return m_lazy_bounds.getBounds();
|
||||
}
|
||||
|
||||
void SetMode( EMode mode ){
|
||||
if ( m_mode != mode ) {
|
||||
m_mode = mode;
|
||||
|
|
@ -5417,11 +5443,11 @@ AABB RadiantSelectionSystem::getSelectionAABB() const {
|
|||
if ( Mode() == eComponent || g_bTmpComponentMode ) {
|
||||
Scene_BoundsSelectedComponent( GlobalSceneGraph(), bounds );
|
||||
if( !aabb_valid( bounds ) ) /* selecting PlaneSelectables sets g_bTmpComponentMode, but only brushes return correct componentEditable->getSelectedComponentsBounds() */
|
||||
Scene_BoundsSelected( GlobalSceneGraph(), bounds );
|
||||
bounds = getBoundsSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
Scene_BoundsSelected( GlobalSceneGraph(), bounds );
|
||||
bounds = getBoundsSelected();
|
||||
}
|
||||
}
|
||||
return bounds;
|
||||
|
|
|
|||
|
|
@ -40,11 +40,4 @@ virtual void incMouseMove( const WindowVector& delta ) = 0;
|
|||
|
||||
SelectionSystemWindowObserver* NewWindowObserver();
|
||||
|
||||
class AABB;
|
||||
namespace scene
|
||||
{
|
||||
class Graph;
|
||||
}
|
||||
void Scene_BoundsSelected( scene::Graph& graph, AABB& bounds );
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2545,7 +2545,7 @@ void XY_Centralize(){
|
|||
|
||||
void GetSelectionBbox( AABB& bounds ){
|
||||
if ( GlobalSelectionSystem().countSelected() != 0 ) {
|
||||
Scene_BoundsSelected( GlobalSceneGraph(), bounds );
|
||||
bounds = GlobalSelectionSystem().getBoundsSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user