Skip to content

Commit

Permalink
Rename PicoModelNode to StaticModelNode
Browse files Browse the repository at this point in the history
Node wrapper class renamed to match StaticModel/StaticModelSurface.
  • Loading branch information
Matthew Mott committed Nov 3, 2020
1 parent 8f2cc49 commit d9d9856
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion radiant/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ darkradiant_SOURCES = main.cpp \
modelfile/Lwo2Exporter.cpp \
modelfile/PicoModelLoader.cpp \
modelfile/PicoModelModule.cpp \
modelfile/PicoModelNode.cpp \
modelfile/StaticModelNode.cpp \
modelfile/StaticModel.cpp \
modelfile/StaticModelSurface.cpp \
modelfile/WavefrontExporter.cpp \
Expand Down
4 changes: 2 additions & 2 deletions radiant/modelfile/PicoModelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "os/path.h"

#include "PicoModelNode.h"
#include "StaticModelNode.h"

#include "idatastream.h"
#include "string/case_conv.h"
Expand Down Expand Up @@ -63,7 +63,7 @@ scene::INodePtr PicoModelLoader::loadModel(const std::string& modelName)
if (picoModel)
{
// Load was successful, construct a modelnode using this resource
return std::make_shared<PicoModelNode>(picoModel);
return std::make_shared<StaticModelNode>(picoModel);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion radiant/modelfile/StaticModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class StaticModel :
void connectUndoSystem(IMapFileChangeTracker& changeTracker);
void disconnectUndoSystem(IMapFileChangeTracker& changeTracker);

// Delegated render methods called by PicoModelNode (not part of any
// Delegated render methods called by StaticModelNode (not part of any
// interface)
void renderSolid(RenderableCollector& rend, const Matrix4& localToWorld,
const IRenderEntity& entity, const LightSources& lights) const;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "PicoModelNode.h"
#include "StaticModelNode.h"

#include "StaticModelSurface.h"
#include "ivolumetest.h"
Expand All @@ -13,89 +13,89 @@
namespace model {

// greebo: Construct a new StaticModel instance, we re-use the surfaces only
PicoModelNode::PicoModelNode(const StaticModelPtr& picoModel) :
StaticModelNode::StaticModelNode(const StaticModelPtr& picoModel) :
_picoModel(new StaticModel(*picoModel)),
_name(picoModel->getFilename()),
_lightList(GlobalRenderSystem().attachLitObject(*this))
{
Node::setTransformChangedCallback(std::bind(&PicoModelNode::lightsChanged, this));
Node::setTransformChangedCallback(std::bind(&StaticModelNode::lightsChanged, this));

// Update the skin
skinChanged("");
}

PicoModelNode::~PicoModelNode() {
StaticModelNode::~StaticModelNode() {
GlobalRenderSystem().detachLitObject(*this);
}

void PicoModelNode::onInsertIntoScene(scene::IMapRootNode& root)
void StaticModelNode::onInsertIntoScene(scene::IMapRootNode& root)
{
_picoModel->connectUndoSystem(root.getUndoChangeTracker());

Node::onInsertIntoScene(root);
}

void PicoModelNode::onRemoveFromScene(scene::IMapRootNode& root)
void StaticModelNode::onRemoveFromScene(scene::IMapRootNode& root)
{
_picoModel->disconnectUndoSystem(root.getUndoChangeTracker());

Node::onRemoveFromScene(root);
}

const IModel& PicoModelNode::getIModel() const
const IModel& StaticModelNode::getIModel() const
{
return *_picoModel;
}

IModel& PicoModelNode::getIModel()
IModel& StaticModelNode::getIModel()
{
return *_picoModel;
}

bool PicoModelNode::hasModifiedScale()
bool StaticModelNode::hasModifiedScale()
{
return _picoModel->getScale() != Vector3(1, 1, 1);
}

Vector3 PicoModelNode::getModelScale()
Vector3 StaticModelNode::getModelScale()
{
return _picoModel->getScale();
}

const AABB& PicoModelNode::localAABB() const {
const AABB& StaticModelNode::localAABB() const {
return _picoModel->localAABB();
}

// SelectionTestable implementation
void PicoModelNode::testSelect(Selector& selector, SelectionTest& test) {
void StaticModelNode::testSelect(Selector& selector, SelectionTest& test) {
_picoModel->testSelect(selector, test, localToWorld());
}

std::string PicoModelNode::name() const {
std::string StaticModelNode::name() const {
return _picoModel->getFilename();
}

scene::INode::Type PicoModelNode::getNodeType() const
scene::INode::Type StaticModelNode::getNodeType() const
{
return Type::Model;
}

const StaticModelPtr& PicoModelNode::getModel() const {
const StaticModelPtr& StaticModelNode::getModel() const {
return _picoModel;
}

void PicoModelNode::setModel(const StaticModelPtr& model) {
void StaticModelNode::setModel(const StaticModelPtr& model) {
_picoModel = model;
}

// LitObject test function
bool PicoModelNode::intersectsLight(const RendererLight& light) const
bool StaticModelNode::intersectsLight(const RendererLight& light) const
{
return light.intersectsAABB(worldAABB());
}

// Add a light to this model instance
void PicoModelNode::insertLight(const RendererLight& light)
void StaticModelNode::insertLight(const RendererLight& light)
{
// Calculate transform from the superclass
const Matrix4& l2w = localToWorld();
Expand All @@ -109,12 +109,12 @@ void PicoModelNode::insertLight(const RendererLight& light)
}

// Clear all lights from this model instance
void PicoModelNode::clearLights()
void StaticModelNode::clearLights()
{
_intersectingLights.clear();
}

void PicoModelNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
void StaticModelNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
{
_lightList.calculateIntersectingLights();

Expand All @@ -131,7 +131,7 @@ void PicoModelNode::renderSolid(RenderableCollector& collector, const VolumeTest
}
}

void PicoModelNode::renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const
void StaticModelNode::renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const
{
assert(_renderEntity);

Expand All @@ -145,21 +145,21 @@ void PicoModelNode::renderWireframe(RenderableCollector& collector, const Volume
}
}

void PicoModelNode::setRenderSystem(const RenderSystemPtr& renderSystem)
void StaticModelNode::setRenderSystem(const RenderSystemPtr& renderSystem)
{
Node::setRenderSystem(renderSystem);

_picoModel->setRenderSystem(renderSystem);
}

// Traceable implementation
bool PicoModelNode::getIntersection(const Ray& ray, Vector3& intersection)
bool StaticModelNode::getIntersection(const Ray& ray, Vector3& intersection)
{
return _picoModel->getIntersection(ray, intersection, localToWorld());
}

// Skin changed notify
void PicoModelNode::skinChanged(const std::string& newSkinName)
void StaticModelNode::skinChanged(const std::string& newSkinName)
{
// The new skin name is stored locally
_skin = newSkinName;
Expand All @@ -174,12 +174,12 @@ void PicoModelNode::skinChanged(const std::string& newSkinName)
}

// Returns the name of the currently active skin
std::string PicoModelNode::getSkin() const
std::string StaticModelNode::getSkin() const
{
return _skin;
}

void PicoModelNode::_onTransformationChanged()
void StaticModelNode::_onTransformationChanged()
{
// Always revert to our original state before evaluating
if (getTransformationType() & TransformationType::Scale)
Expand All @@ -196,7 +196,7 @@ void PicoModelNode::_onTransformationChanged()
}
}

void PicoModelNode::_applyTransformation()
void StaticModelNode::_applyTransformation()
{
if (getTransformationType() & TransformationType::Scale)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace model {
* \brief
* Scenegraph node representing a static model
*/
class PicoModelNode :
class StaticModelNode :
public scene::Node,
public ModelNode,
public SelectionTestable,
Expand All @@ -26,7 +26,6 @@ class PicoModelNode :
public ITraceable,
public Transformable
{
private:
// The actual model
StaticModelPtr _picoModel;

Expand All @@ -43,11 +42,13 @@ class PicoModelNode :
std::string _skin;

public:
/** Construct a PicoModelNode with a reference to the loaded picoModel.
typedef std::shared_ptr<StaticModelNode> Ptr;

/** Construct a StaticModelNode with a reference to the loaded picoModel.
*/
PicoModelNode(const StaticModelPtr& picoModel);
StaticModelNode(const StaticModelPtr& picoModel);

virtual ~PicoModelNode();
virtual ~StaticModelNode();

virtual void onInsertIntoScene(scene::IMapRootNode& root) override;
virtual void onRemoveFromScene(scene::IMapRootNode& root) override;
Expand Down Expand Up @@ -106,6 +107,5 @@ class PicoModelNode :
virtual void _onTransformationChanged() override;
virtual void _applyTransformation() override;
};
typedef std::shared_ptr<PicoModelNode> PicoModelNodePtr;

} // namespace model

0 comments on commit d9d9856

Please sign in to comment.