Skip to content

Commit

Permalink
Move some implementation to ManipulationPivot.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 19, 2016
1 parent c9669b4 commit 489f407
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 33 deletions.
1 change: 1 addition & 0 deletions radiant/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ darkradiant_SOURCES = main.cpp \
selection/algorithm/General.cpp \
selection/algorithm/Planes.cpp \
selection/BestPoint.cpp \
selection/ManipulationPivot.cpp \
selection/manipulators/DragManipulator.cpp \
selection/RadiantSelectionSystem.cpp \
selection/manipulators/RotateManipulator.cpp \
Expand Down
49 changes: 49 additions & 0 deletions radiant/selection/ManipulationPivot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "ManipulationPivot.h"

namespace selection
{

// Returns the pivot-to-world transform
const Matrix4& ManipulationPivot::getMatrix4() const
{
return _pivot2World;
}

// Returns the position of the pivot point relative to origin
const Vector3& ManipulationPivot::getVector3() const
{
return _pivot2World.t().getVector3();
}

void ManipulationPivot::setFromMatrix(const Matrix4& newPivot2World)
{
_pivot2World = newPivot2World;
}

// Call this before an operation is started, such that later
// transformations can be applied on top of the correct starting point
void ManipulationPivot::beginOperation()
{
_pivot2WorldStart = _pivot2World;
}

// Reverts the matrix to the state it had at the beginning of the operation
void ManipulationPivot::revertToStart()
{
_pivot2World = _pivot2WorldStart;
}

void ManipulationPivot::endOperation()
{
_pivot2WorldStart = _pivot2World;
}

void ManipulationPivot::applyTranslation(const Vector3& translation)
{
// We apply translations on top of the starting point
revertToStart();

_pivot2World.translateBy(translation);
}

}
39 changes: 8 additions & 31 deletions radiant/selection/ManipulationPivot.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "math/Matrix4.h"
#include "math/Vector3.h"

namespace selection
{
Expand All @@ -25,47 +26,23 @@ class ManipulationPivot

public:
// Returns the pivot-to-world transform
const Matrix4& getMatrix4() const
{
return _pivot2World;
}
const Matrix4& getMatrix4() const;

// Returns the position of the pivot point relative to origin
const Vector3& getVector3() const
{
return _pivot2World.t().getVector3();
}
const Vector3& getVector3() const;

void setFromMatrix(const Matrix4& newPivot2World)
{
_pivot2World = newPivot2World;
}
void setFromMatrix(const Matrix4& newPivot2World);

// Call this before an operation is started, such that later
// transformations can be applied on top of the correct starting point
void beginOperation()
{
_pivot2WorldStart = _pivot2World;
}
void beginOperation();

// Reverts the matrix to the state it had at the beginning of the operation
void revertToStart()
{
_pivot2World = _pivot2WorldStart;
}
void revertToStart();

void endOperation()
{
_pivot2WorldStart = _pivot2World;
}
void endOperation();

void applyTranslation(const Vector3& translation)
{
// We apply translations on top of the starting point
revertToStart();

_pivot2World.translateBy(translation);
}
void applyTranslation(const Vector3& translation);
};

}
2 changes: 0 additions & 2 deletions radiant/selection/RadiantSelectionSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class RadiantSelectionSystem :
{
ManipulationPivot _pivot;

Matrix4 _manip2pivotStart;

typedef std::list<Observer*> ObserverList;
ObserverList _observers;

Expand Down
1 change: 1 addition & 0 deletions tools/msvc2015/DarkRadiant.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
<ClCompile Include="..\..\radiant\selection\group\SelectionGroupInfoFileModule.cpp" />
<ClCompile Include="..\..\radiant\selection\group\SelectionGroupManager.cpp" />
<ClCompile Include="..\..\radiant\selection\ManipulateMouseTool.cpp" />
<ClCompile Include="..\..\radiant\selection\ManipulationPivot.cpp" />
<ClCompile Include="..\..\radiant\selection\manipulators\DragManipulator.cpp" />
<ClCompile Include="..\..\radiant\selection\manipulators\ManipulatorBase.cpp" />
<ClCompile Include="..\..\radiant\selection\manipulators\ManipulatorComponents.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions tools/msvc2015/DarkRadiant.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,9 @@
<ClCompile Include="..\..\radiant\selection\algorithm\Planes.cpp">
<Filter>src\selection\algorithm</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\selection\ManipulationPivot.cpp">
<Filter>src\selection</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiant\RadiantModule.h">
Expand Down

0 comments on commit 489f407

Please sign in to comment.