Skip to content

Commit

Permalink
#5643: Add "FocusView" command accepting two vector3 arguments (origi…
Browse files Browse the repository at this point in the history
…n and angles). Implement Jump to next Conflict functionality.
  • Loading branch information
codereader committed Jun 21, 2021
1 parent f159b4c commit 58dde92
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 154 deletions.
249 changes: 166 additions & 83 deletions install/ui/mergecontroldialog.fbp

Large diffs are not rendered by default.

78 changes: 48 additions & 30 deletions install/ui/mergecontroldialog.xrc
Expand Up @@ -194,7 +194,7 @@
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxBOTTOM|wxTOP</flag>
<flag>wxTOP</flag>
<border>6</border>
<object class="wxStaticText" name="m_staticText14">
<font>
Expand All @@ -208,19 +208,19 @@
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND|wxLEFT</flag>
<flag>wxEXPAND|wxLEFT|wxTOP</flag>
<border>12</border>
<object class="wxFlexGridSizer">
<rows>4</rows>
<cols>4</cols>
<vgap>0</vgap>
<vgap>6</vgap>
<hgap>0</hgap>
<growablecols>1,3</growablecols>
<growablerows></growablerows>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_RIGHT|wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT</flag>
<border>6</border>
<object class="wxStaticText" name="EntitiesAdded">
<font>
<style>normal</style>
Expand All @@ -233,17 +233,17 @@
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>0</border>
<object class="wxStaticText" name="m_staticText42">
<label>Entities to be added</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT</flag>
<border>6</border>
<object class="wxStaticText" name="EntitiesRemoved">
<font>
<style>normal</style>
Expand All @@ -256,17 +256,17 @@
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>0</border>
<object class="wxStaticText" name="m_staticText24">
<label>Entities to be removed</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_RIGHT|wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT</flag>
<border>6</border>
<object class="wxStaticText" name="EntitiesModified">
<font>
<style>normal</style>
Expand All @@ -279,8 +279,8 @@
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>0</border>
<object class="wxStaticText" name="m_staticText28">
<label>Entities to be modified</label>
<wrap>-1</wrap>
Expand All @@ -304,8 +304,8 @@
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_RIGHT|wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT</flag>
<border>6</border>
<object class="wxStaticText" name="PrimitivesAdded">
<font>
<style>normal</style>
Expand All @@ -318,17 +318,17 @@
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>0</border>
<object class="wxStaticText" name="m_staticText29">
<label>Primitives to be added</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_RIGHT|wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT</flag>
<border>6</border>
<object class="wxStaticText" name="PrimitivesRemoved">
<font>
<style>normal</style>
Expand All @@ -341,17 +341,17 @@
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>0</border>
<object class="wxStaticText" name="m_staticText22">
<label>Primitives to be removed</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<flag>wxALIGN_CENTER_VERTICAL|wxRIGHT</flag>
<border>6</border>
<object class="wxStaticText" name="UnresolvedConflicts">
<font>
<style>normal</style>
Expand All @@ -363,12 +363,30 @@
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxStaticText" name="UnresolvedConflictsLabel">
<label>Unresolved Conflicts</label>
<wrap>-1</wrap>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>0</border>
<object class="wxStaticText" name="UnresolvedConflictsLabel">
<label>Unresolved Conflicts</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxLEFT</flag>
<border>6</border>
<object class="wxBitmapButton" name="JumpToNextConflictButton">
<tooltip>Jump to next conflict</tooltip>
<bitmap stock_id="wxART_GO_FORWARD" stock_client="">undefined.png</bitmap>
<default>0</default>
</object>
</object>
</object>
</object>
</object>
Expand Down
17 changes: 17 additions & 0 deletions libs/scenelib.h
Expand Up @@ -6,6 +6,7 @@
#include "iselectable.h"
#include "ipatch.h"
#include "ibrush.h"
#include "icameraview.h"

#include "scene/Node.h"

Expand Down Expand Up @@ -282,4 +283,20 @@ inline void assignVisibilityFlagsFromNode(INode& target, const INode& source)
}
}

inline std::pair<Vector3, Vector3> getOriginAndAnglesToLookAtNode(const scene::INode& node)
{
const AABB& aabb = node.worldAABB();
Vector3 origin(aabb.origin);

// Move the camera a bit off the AABB origin
origin += Vector3(aabb.extents.getLength() * 5, 0, aabb.extents.getLength() * 5);

// Rotate the camera a bit towards the "ground"
Vector3 angles(0, 0, 0);
angles[camera::CAMERA_PITCH] = -40;
angles[camera::CAMERA_YAW] = 180;

return std::make_pair(origin, angles);
}

} // namespace scene
15 changes: 4 additions & 11 deletions radiant/ui/entitylist/EntityList.cpp
Expand Up @@ -2,9 +2,11 @@

#include "ieventmanager.h"
#include "imainframe.h"
#include "icommandsystem.h"

#include "registry/Widgets.h"
#include "entitylib.h"
#include "scenelib.h"
#include "iselectable.h"
#include "icameraview.h"
#include "i18n.h"
Expand Down Expand Up @@ -332,17 +334,8 @@ void EntityList::onSelection(wxDataViewEvent& ev)

if (isSelected && _focusSelected->GetValue())
{
const AABB& aabb = node->worldAABB();
Vector3 origin(aabb.origin);

// Move the camera a bit off the AABB origin
origin += Vector3(-50, 0, 50);

// Rotate the camera a bit towards the "ground"
Vector3 angles(0, 0, 0);
angles[camera::CAMERA_PITCH] = -30;

GlobalCameraManager().focusAllCameras(origin, angles);
auto originAndAngles = scene::getOriginAndAnglesToLookAtNode(*node);
GlobalCommandSystem().executeCommand("FocusViews", cmd::ArgumentList{ originAndAngles.first, originAndAngles.second });
}

// Now reactivate the callbacks
Expand Down

0 comments on commit 58dde92

Please sign in to comment.