Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/orbweaver/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 21, 2020
2 parents 39de2db + 5ae45ca commit 6054321
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 115 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Expand Up @@ -27,7 +27,7 @@ endif()
# Build shared libraries by default
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
if (${ENABLE_RELOCATION})
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib/darkradiant")
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/darkradiant")
else()
set(CMAKE_INSTALL_RPATH "${PKGLIBDIR}")
endif()
Expand Down Expand Up @@ -56,6 +56,7 @@ pkg_check_modules(AL openal REQUIRED)
pkg_check_modules(OGG ogg REQUIRED)
pkg_check_modules(VORBIS vorbisfile REQUIRED)
pkg_check_modules(X11 x11 REQUIRED)
pkg_check_modules(ZLIB zlib REQUIRED)

# Locate wxWidgets
find_package(wxWidgets REQUIRED
Expand Down
3 changes: 0 additions & 3 deletions include/irender.h
Expand Up @@ -194,9 +194,6 @@ class RendererLight
*/
virtual Matrix4 getLightTextureTransformation() const = 0;

/// Return true if this light intersects the given AABB
virtual bool intersectsAABB(const AABB& aabb) const = 0;

/**
* \brief
* Return the AABB of the illuminated volume.
Expand Down
4 changes: 0 additions & 4 deletions plugins/script/ScriptingSystem.cpp
Expand Up @@ -300,11 +300,7 @@ void ScriptingSystem::initialiseModule(const IApplicationContext& ctx)
.connect(sigc::mem_fun(this, &ScriptingSystem::initialise));

// Construct the script path
#if defined(POSIX) && defined(PKGLIBDIR)
_scriptPath = std::string(PKGLIBDIR) + "/scripts/";
#else
_scriptPath = ctx.getRuntimeDataPath() + "scripts/";
#endif

// Set up the python interpreter
_pythonModule.reset(new PythonModule);
Expand Down
75 changes: 41 additions & 34 deletions radiant/ui/einspector/Vector3PropertyEditor.cpp
Expand Up @@ -16,56 +16,63 @@
namespace ui
{

// Blank ctor
static const int RANGE_MAX = 32767;
static const int RANGE_MIN = -32767;

wxSpinCtrl* makeSpinCtrl(wxPanel* parent)
{
wxSpinCtrl* ctrl = new wxSpinCtrl(parent, wxID_ANY);

// Set an appropriate minimum size based on the expected contents
static const wxSize minSize = ctrl->GetSizeFromTextSize(
ctrl->GetTextExtent(std::to_string(RANGE_MIN)).GetWidth()
);
ctrl->SetMinSize(minSize);

// Set value and range
ctrl->SetValue(0);
ctrl->SetRange(RANGE_MIN, RANGE_MAX);

return ctrl;
}

// Blank ctor
Vector3PropertyEditor::Vector3PropertyEditor() {}

// Constructor. Create the widgets here
Vector3PropertyEditor::Vector3PropertyEditor(wxWindow* parent, Entity* entity,
const std::string& name)
const std::string& name)
: PropertyEditor(entity),
_key(name)
{
// Construct the main widget (will be managed by the base class)
wxPanel* mainVBox = new wxPanel(parent, wxID_ANY);
mainVBox->SetSizer(new wxBoxSizer(wxHORIZONTAL));
// Construct the main widget (will be managed by the base class)
wxPanel* mainVBox = new wxPanel(parent, wxID_ANY);
mainVBox->SetSizer(new wxBoxSizer(wxHORIZONTAL));

// Register the main widget in the base class
setMainWidget(mainVBox);
// Register the main widget in the base class
setMainWidget(mainVBox);

// Create the spin buttons
_xValue = new wxSpinCtrl(mainVBox, wxID_ANY);
_yValue = new wxSpinCtrl(mainVBox, wxID_ANY);
_zValue = new wxSpinCtrl(mainVBox, wxID_ANY);

_xValue->SetMinSize(wxSize(75, -1));
_yValue->SetMinSize(wxSize(75, -1));
_zValue->SetMinSize(wxSize(75, -1));

_xValue->SetValue(0);
_yValue->SetValue(0);
_zValue->SetValue(0);

_xValue->SetRange(-32767, 32767);
_yValue->SetRange(-32767, 32767);
_zValue->SetRange(-32767, 32767);
_xValue = makeSpinCtrl(mainVBox);
_yValue = makeSpinCtrl(mainVBox);
_zValue = makeSpinCtrl(mainVBox);

// Add the spin buttons to the HBox with labels
mainVBox->GetSizer()->Add(new wxStaticText(mainVBox, wxID_ANY, _("X: ")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(_xValue, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(new wxStaticText(mainVBox, wxID_ANY, _(" Y: ")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(_yValue, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(new wxStaticText(mainVBox, wxID_ANY, _(" Z: ")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(_zValue, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(new wxStaticText(mainVBox, wxID_ANY, _("X: ")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(_xValue, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(new wxStaticText(mainVBox, wxID_ANY, _(" Y: ")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(_yValue, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(new wxStaticText(mainVBox, wxID_ANY, _(" Z: ")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
mainVBox->GetSizer()->Add(_zValue, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);

// Create the apply button
wxButton* applyButton = new wxButton(mainVBox, wxID_APPLY, _("Apply..."));
applyButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(Vector3PropertyEditor::_onApply), NULL, this);
// Create the apply button
wxButton* applyButton = new wxButton(mainVBox, wxID_APPLY, _("Apply..."));
applyButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(Vector3PropertyEditor::_onApply), NULL, this);

mainVBox->GetSizer()->Add(applyButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6);
mainVBox->GetSizer()->Add(applyButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6);

// Populate the spin boxes from the keyvalue
updateFromEntity();
// Populate the spin boxes from the keyvalue
updateFromEntity();
}

void Vector3PropertyEditor::updateFromEntity()
Expand Down
11 changes: 9 additions & 2 deletions radiant/ui/mainframe/FloatingLayout.h
Expand Up @@ -14,8 +14,15 @@ typedef std::shared_ptr<FloatingCamWnd> FloatingCamWndPtr;
class FloatingLayout;
typedef std::shared_ptr<FloatingLayout> FloatingLayoutPtr;

class FloatingLayout :
public IMainFrameLayout
/**
* \brief
* Original GIMP-style layout with multiple floating windows
*
* This layout is the most flexible, as it allows windows to be positioned and
* resized arbitrarily, but it is also more cumbersome to set up because the
* default window positions are not likely to be desirable.
*/
class FloatingLayout: public IMainFrameLayout
{
// The floating camera window
FloatingCamWndPtr _floatingCamWnd;
Expand Down
19 changes: 9 additions & 10 deletions radiant/ui/mainframe/RegularLayout.cpp
Expand Up @@ -135,18 +135,17 @@ void RegularLayout::restoreStateFromPath(const std::string& path)
{
// Trigger a proper resize event before setting the sash position
GlobalMainFrame().getWxTopLevelWindow()->SendSizeEvent();
wxTheApp->Yield();

// Now load the paned positions from the registry
if (GlobalRegistry().keyExists(path + "/pane[@name='horizontal']"))
{
_regular.posHPane.loadFromPath(path + "/pane[@name='horizontal']");
}
// Now load the paned positions from the registry
if (GlobalRegistry().keyExists(path + "/pane[@name='horizontal']"))
{
_regular.posHPane.loadFromPath(path + "/pane[@name='horizontal']");
}

if (GlobalRegistry().keyExists(path + "/pane[@name='texcam']"))
{
_regular.posTexCamPane.loadFromPath(path + "/pane[@name='texcam']");
}
if (GlobalRegistry().keyExists(path + "/pane[@name='texcam']"))
{
_regular.posTexCamPane.loadFromPath(path + "/pane[@name='texcam']");
}
}

void RegularLayout::restoreStateFromRegistry()
Expand Down
2 changes: 1 addition & 1 deletion radiant/uimanager/GroupDialog.cpp
Expand Up @@ -88,7 +88,7 @@ void GroupDialog::populateWindow()
panel->SetSizer(new wxBoxSizer(wxVERTICAL));

wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
panel->GetSizer()->Add(vbox, 1, wxEXPAND | wxALL, 12);
panel->GetSizer()->Add(vbox, 1, wxEXPAND);

_notebook = new wxNotebook(panel, wxID_ANY,
wxDefaultPosition, wxDefaultSize, wxNB_TOP, "GroupDialogNB");
Expand Down
14 changes: 6 additions & 8 deletions radiant/uimanager/GroupDialog.h
Expand Up @@ -12,6 +12,12 @@ class wxNotebook;
class wxBookCtrlEvent;
class wxImageList;

namespace ui
{

class GroupDialog;
typedef std::shared_ptr<GroupDialog> GroupDialogPtr;

/**
* greebo: The GroupDialog class creates the Window and the Notebook widget
* as soon as construct() is called.
Expand All @@ -24,18 +30,10 @@ class wxImageList;
* The name passed to the addPage() method can be used to directly toggle
* the notebook widgets via setPage(<name>).
*/

namespace ui
{

class GroupDialog;
typedef std::shared_ptr<GroupDialog> GroupDialogPtr;

class GroupDialog :
public wxutil::TransientWindow,
public IGroupDialog
{
private:
// Pages, sorted by position
typedef std::map<int, Page> Pages;

Expand Down
2 changes: 1 addition & 1 deletion radiantcore/CMakeLists.txt
Expand Up @@ -279,4 +279,4 @@ target_compile_options(radiantcore PUBLIC ${SIGC_CFLAGS})
target_include_directories(radiantcore PRIVATE .)
target_link_libraries(radiantcore PUBLIC
math xmlutil scenegraph wxutil module
${JPEG_LIBRARIES} ${PNG_LIBRARIES})
${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
2 changes: 1 addition & 1 deletion radiantcore/brush/BrushNode.cpp
Expand Up @@ -296,7 +296,7 @@ void BrushNode::DEBUG_verify() {
}

bool BrushNode::intersectsLight(const RendererLight& light) const {
return light.intersectsAABB(worldAABB());
return light.lightAABB().intersects(worldAABB());
}

void BrushNode::renderComponents(RenderableCollector& collector, const VolumeTest& volume) const
Expand Down
50 changes: 4 additions & 46 deletions radiantcore/entity/light/Light.cpp
Expand Up @@ -730,60 +730,18 @@ Matrix4 Light::getLightTextureTransformation() const
// outside the volume), used for drag manipulator and render culling.
AABB Light::lightAABB() const
{
if (isProjected())
// Return Frustum AABB in *world* space
return _frustum.getTransformedBy(_owner.localToParent()).getAABB();
else
return AABB(_originTransformed, m_doom3Radius.m_radiusTransformed);
}

bool Light::intersectsAABB(const AABB& other) const
{
bool returnVal;

if (isProjected())
{
// Update the projection, including the Frustum (we don't care about the
// projection matrix itself).
// Make sure our frustum is up to date
updateProjection();

// Construct a transformation with the rotation and translation of the
// frustum
Matrix4 transRot = Matrix4::getIdentity();
transRot.translateBy(worldOrigin());
transRot.multiplyBy(rotation());

// Transform the frustum with the rotate/translate matrix and test its
// intersection with the AABB
Frustum frustumTrans = _frustum.getTransformedBy(transRot);

VolumeIntersectionValue intersects = frustumTrans.testIntersection(other);

returnVal = intersects != VOLUME_OUTSIDE;
// Return Frustum AABB in *world* space
return _frustum.getTransformedBy(_owner.localToParent()).getAABB();
}
else
{
// test against an AABB which contains the rotated bounds of this light.
AABB bounds = localAABB();
bounds.origin += worldOrigin();

returnVal = other.intersects(AABB(
bounds.origin,
Vector3(
static_cast<float>(fabs(m_rotation[0] * bounds.extents[0])
+ fabs(m_rotation[3] * bounds.extents[1])
+ fabs(m_rotation[6] * bounds.extents[2])),
static_cast<float>(fabs(m_rotation[1] * bounds.extents[0])
+ fabs(m_rotation[4] * bounds.extents[1])
+ fabs(m_rotation[7] * bounds.extents[2])),
static_cast<float>(fabs(m_rotation[2] * bounds.extents[0])
+ fabs(m_rotation[5] * bounds.extents[1])
+ fabs(m_rotation[8] * bounds.extents[2]))
)
));
return AABB(_originTransformed, m_doom3Radius.m_radiusTransformed);
}

return returnVal;
}

const Matrix4& Light::rotation() const {
Expand Down
1 change: 0 additions & 1 deletion radiantcore/entity/light/Light.h
Expand Up @@ -262,7 +262,6 @@ class Light :
const IRenderEntity& getLightEntity() const override;
const Vector3& worldOrigin() const override;
Matrix4 getLightTextureTransformation() const override;
bool intersectsAABB(const AABB& other) const override;
Vector3 getLightOrigin() const override;
const ShaderPtr& getShader() const override;

Expand Down
2 changes: 1 addition & 1 deletion radiantcore/model/md5/MD5ModelNode.cpp
Expand Up @@ -69,7 +69,7 @@ bool MD5ModelNode::getIntersection(const Ray& ray, Vector3& intersection)

bool MD5ModelNode::intersectsLight(const RendererLight& light) const
{
return light.intersectsAABB(worldAABB());
return light.lightAABB().intersects(worldAABB());
}

void MD5ModelNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/model/picomodel/StaticModelNode.cpp
Expand Up @@ -87,7 +87,7 @@ void StaticModelNode::setModel(const StaticModelPtr& model) {
// LitObject test function
bool StaticModelNode::intersectsLight(const RendererLight& light) const
{
return light.intersectsAABB(worldAABB());
return light.lightAABB().intersects(worldAABB());
}

void StaticModelNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/patch/PatchNode.cpp
Expand Up @@ -262,7 +262,7 @@ bool PatchNode::getIntersection(const Ray& ray, Vector3& intersection)
}

bool PatchNode::intersectsLight(const RendererLight& light) const {
return light.intersectsAABB(worldAABB());
return light.lightAABB().intersects(worldAABB());
}

void PatchNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
Expand Down

0 comments on commit 6054321

Please sign in to comment.