Skip to content

Commit

Permalink
Merge branch 'NewArchitecture' of github.com:kduske/TrenchBroom into …
Browse files Browse the repository at this point in the history
…NewArchitecture
  • Loading branch information
kduske committed Jul 30, 2014
2 parents 112f72e + 6df54b5 commit b0e1b76
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 23 deletions.
13 changes: 7 additions & 6 deletions common/src/Model/ParaxialTexCoordSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,15 @@ namespace TrenchBroom {
// WARNING: the texture plane norm is not the rotation axis of the texture (it's always the absolute axis)

// determine the rotation angle from the dot product of the new base axes and the transformed texture axes
float cosX = static_cast<float>(newBaseXAxis.dot(newXAxis));
assert(!Math::isnan(cosX));
float radX = std::acos(cosX);
if (crossed(newBaseXAxis, newXAxis).dot(newProjectionAxis) < 0.0)
radX *= -1.0f;
// we prefer the Y axis over the X axis because this usually gives better results on most brushes
float cosY = static_cast<float>(newBaseYAxis.dot(newYAxis));
assert(!Math::isnan(cosY));
float radY = std::acos(cosY);
if (crossed(newBaseYAxis, newYAxis).dot(newProjectionAxis) < 0.0)
radY *= -1.0f;

// for some reason, when the texture plane normal is the Y axis, we must rotation clockwise
float rad = radX;
float rad = radY;
if (newIndex == 4)
rad *= -1.0f;

Expand Down
7 changes: 7 additions & 0 deletions common/src/Renderer/MapRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ namespace TrenchBroom {
document->faceDidChangeNotifier.addObserver(this, &MapRenderer::faceDidChange);
document->selectionDidChangeNotifier.addObserver(this, &MapRenderer::selectionDidChange);
document->modsDidChangeNotifier.addObserver(this, &MapRenderer::modsDidChange);
document->textureCollectionsDidChangeNotifier.addObserver(this, &MapRenderer::textureCollectionsDidChange);
document->entityDefinitionsDidChangeNotifier.addObserver(this, &MapRenderer::entityDefinitionsDidChange);

PreferenceManager& prefs = PreferenceManager::instance();
Expand All @@ -181,6 +182,7 @@ namespace TrenchBroom {
document->faceDidChangeNotifier.removeObserver(this, &MapRenderer::faceDidChange);
document->selectionDidChangeNotifier.removeObserver(this, &MapRenderer::selectionDidChange);
document->modsDidChangeNotifier.removeObserver(this, &MapRenderer::modsDidChange);
document->textureCollectionsDidChangeNotifier.removeObserver(this, &MapRenderer::textureCollectionsDidChange);
document->entityDefinitionsDidChangeNotifier.removeObserver(this, &MapRenderer::entityDefinitionsDidChange);
}

Expand Down Expand Up @@ -283,6 +285,11 @@ namespace TrenchBroom {
m_selectedEntityRenderer.reloadModels();
}

void MapRenderer::textureCollectionsDidChange() {
m_unselectedBrushRenderer.invalidate();
m_selectedBrushRenderer.invalidate();
}

void MapRenderer::preferenceDidChange(const IO::Path& path) {
View::MapDocumentSPtr document = lock(m_document);
if (document->isGamePathPreference(path)) {
Expand Down
1 change: 1 addition & 0 deletions common/src/Renderer/MapRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace TrenchBroom {
void selectionDidChange(const Model::SelectionResult& result);
void modsDidChange();
void entityDefinitionsDidChange();
void textureCollectionsDidChange();
void preferenceDidChange(const IO::Path& path);

void clearState();
Expand Down
12 changes: 7 additions & 5 deletions common/src/TrenchBroomApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ namespace TrenchBroom {
// we must delete the recent documents here instead of in OnExit because they might still be used by the frame destructors
delete m_recentDocuments;
m_recentDocuments = NULL;

// The config manager is deleted before the persistence manager has a chance to save its data. This leads
// to the config manager getting recreated, but not flushed, so we explicitly delete it again here.
delete wxConfig::Set(NULL);
}

FrameManager* TrenchBroomApp::frameManager() {
Expand Down Expand Up @@ -242,6 +238,12 @@ namespace TrenchBroom {
}
}

int TrenchBroomApp::OnRun() {
const int result = wxApp::OnRun();
DeletePendingObjects();
return result;
}

void TrenchBroomApp::OnFileNew(wxCommandEvent& event) {
newDocument();
}
Expand Down Expand Up @@ -292,7 +294,7 @@ namespace TrenchBroom {
#ifdef __APPLE__
void TrenchBroomApp::OnFileExit(wxCommandEvent& event) {
if (m_frameManager->closeAllFrames())
Exit();
ExitMainLoop();
}

void TrenchBroomApp::OnUpdateUI(wxUpdateUIEvent& event) {
Expand Down
2 changes: 2 additions & 0 deletions common/src/TrenchBroomApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace TrenchBroom {
int OnExit();
void OnUnhandledException();

int OnRun();

void OnFileNew(wxCommandEvent& event);
void OnFileOpen(wxCommandEvent& event);
void OnFileOpenRecent(wxCommandEvent& event);
Expand Down
3 changes: 1 addition & 2 deletions common/src/View/PersistentSplitterWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ namespace TrenchBroom {

void PersistentSplitterWindow::Save() const {
const SplitterWindow* window = Get();
if (window->m_sashPosition > 0)
SaveValue("SashPosition", window->m_sashPosition);
SaveValue("SashPosition", window->m_sashPosition);
}

bool PersistentSplitterWindow::Restore() {
Expand Down
26 changes: 16 additions & 10 deletions common/src/View/SplitterWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace TrenchBroom {

Bind(wxEVT_MOUSE_CAPTURE_LOST, &SplitterWindow::OnMouseCaptureLost, this);
Bind(wxEVT_SIZE, &SplitterWindow::OnSize, this);
Bind(wxEVT_IDLE, &SplitterWindow::OnIdle, this);
}

void SplitterWindow::splitHorizontally(wxWindow* left, wxWindow* right, const wxSize& leftMin, const wxSize& rightMin) {
Expand Down Expand Up @@ -178,6 +179,14 @@ namespace TrenchBroom {
}
}

void SplitterWindow::OnIdle(wxIdleEvent& event) {
if (IsShownOnScreen()) {
Unbind(wxEVT_IDLE, &SplitterWindow::OnIdle, this);

// if the initial sash position could not be set until now, then it probably cannot be set at all
m_initialSashPosition = -1;
}
}
void SplitterWindow::OnSize(wxSizeEvent& event) {
updateSashPosition(m_oldSize, event.GetSize());
sizeWindows();
Expand All @@ -189,15 +198,10 @@ namespace TrenchBroom {
initSashPosition();

if (m_splitMode != SplitMode_Unset) {
if (m_initialSashPosition != -1) {
if (setSashPosition(m_initialSashPosition))
m_initialSashPosition = -1;
} else {
const wxSize diff = newSize - oldSize;
const int actualDiff = wxRound(m_sashGravity * h(diff));
if (actualDiff != 0)
setSashPosition(m_sashPosition + actualDiff);
}
const wxSize diff = newSize - oldSize;
const int actualDiff = wxRound(m_sashGravity * h(diff));
if (actualDiff != 0)
setSashPosition(m_sashPosition + actualDiff);
}
}

Expand All @@ -206,7 +210,9 @@ namespace TrenchBroom {
setSashPosition(h(m_minSizes[0]) + wxRound(m_sashGravity * (h(m_minSizes[1]) - h(m_minSizes[0]))) + 1);
}

bool SplitterWindow::setSashPosition(const int position) {
bool SplitterWindow::setSashPosition(int position) {
if (m_initialSashPosition != -1)
position = m_initialSashPosition;
if (position == m_sashPosition)
return true;
m_sashPosition = position;
Expand Down
1 change: 1 addition & 0 deletions common/src/View/SplitterWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace TrenchBroom {
void unsetSashCursor();
wxCursor sizeCursor() const;
public:
void OnIdle(wxIdleEvent& event);
void OnSize(wxSizeEvent& event);
private:
void updateSashPosition(const wxSize& oldSize, const wxSize& newSize);
Expand Down

0 comments on commit b0e1b76

Please sign in to comment.