Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#5584: Remove unneeded renderable classes from NullModel. Cleanup the…
… class a bit.
  • Loading branch information
codereader committed Jan 25, 2022
1 parent 9ba8328 commit 8601fa7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 52 deletions.
55 changes: 23 additions & 32 deletions radiantcore/model/NullModel.cpp
@@ -1,75 +1,66 @@
#include "NullModel.h"

#include "math/Frustum.h"
#include "irenderable.h"
#include <stdexcept>

namespace model {
namespace model
{

NullModel::NullModel() :
_aabbLocal(Vector3(0, 0, 0), Vector3(8, 8, 8)),
_aabbSolid(_aabbLocal),
_aabbWire(_aabbLocal)
_aabbLocal(Vector3(0, 0, 0), Vector3(8, 8, 8))
{}

NullModel::~NullModel() {
_state = ShaderPtr();
}

const AABB& NullModel::localAABB() const {
const AABB& NullModel::localAABB() const
{
return _aabbLocal;
}

void NullModel::testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld)
std::string NullModel::getFilename() const
{
test.BeginMesh(localToWorld);

SelectionIntersection best;
aabb_testselect(_aabbLocal, test, best);

if(best.isValid()) {
selector.addIntersection(best);
}
}

std::string NullModel::getFilename() const {
return _filename;
}

void NullModel::setFilename(const std::string& filename) {
void NullModel::setFilename(const std::string& filename)
{
_filename = filename;
}

std::string NullModel::getModelPath() const {
std::string NullModel::getModelPath() const
{
return _modelPath;
}

void NullModel::setModelPath(const std::string& modelPath) {
void NullModel::setModelPath(const std::string& modelPath)
{
_modelPath = modelPath;
}

void NullModel::applySkin(const ModelSkin& skin) {
void NullModel::applySkin(const ModelSkin& skin)
{
// do nothing
}

int NullModel::getSurfaceCount() const {
int NullModel::getSurfaceCount() const
{
return 0;
}

int NullModel::getVertexCount() const {
int NullModel::getVertexCount() const
{
return 0;
}

int NullModel::getPolyCount() const {
int NullModel::getPolyCount() const
{
return 0;
}

const IModelSurface& NullModel::getSurface(unsigned surfaceNum) const
{
throw new std::runtime_error("NullModel::getSurface: invalid call, no surfaces.");
throw std::runtime_error("NullModel::getSurface: invalid call, no surfaces.");
}

const StringList& NullModel::getActiveMaterials() const {
const StringList& NullModel::getActiveMaterials() const
{
static std::vector<std::string> _dummyMaterials;
return _dummyMaterials;
}
Expand Down
30 changes: 12 additions & 18 deletions radiantcore/model/NullModel.h
Expand Up @@ -2,43 +2,37 @@

#include "imodel.h"
#include "math/AABB.h"
#include "entitylib.h"

namespace model {
namespace model
{

class NullModel :
class NullModel final :
public IModel
{
ShaderPtr _state;
AABB _aabbLocal;
RenderableSolidAABB _aabbSolid;
RenderableWireframeAABB _aabbWire;

std::string _filename;
std::string _modelPath;
public:
NullModel();
virtual ~NullModel();

const AABB& localAABB() const;

void testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld);
const AABB& localAABB() const override;

// IModel implementation
virtual std::string getFilename() const;
std::string getFilename() const override;
void setFilename(const std::string& filename);

virtual std::string getModelPath() const;
std::string getModelPath() const override;
void setModelPath(const std::string& modelPath);

virtual void applySkin(const ModelSkin& skin);
void applySkin(const ModelSkin& skin) override;

virtual int getSurfaceCount() const;
virtual int getVertexCount() const;
virtual int getPolyCount() const;
virtual const IModelSurface& getSurface(unsigned surfaceNum) const;
int getSurfaceCount() const override;
int getVertexCount() const override;
int getPolyCount() const override;
const IModelSurface& getSurface(unsigned surfaceNum) const override;

virtual const std::vector<std::string>& getActiveMaterials() const;
const std::vector<std::string>& getActiveMaterials() const override;
};
typedef std::shared_ptr<NullModel> NullModelPtr;

Expand Down
11 changes: 10 additions & 1 deletion radiantcore/model/NullModelNode.cpp
@@ -1,6 +1,7 @@
#include "NullModelNode.h"

#include "math/Frustum.h"
#include "entitylib.h"

namespace model
{
Expand Down Expand Up @@ -47,7 +48,15 @@ Vector3 NullModelNode::getModelScale()

void NullModelNode::testSelect(Selector& selector, SelectionTest& test)
{
_nullModel->testSelect(selector, test, localToWorld());
test.BeginMesh(localToWorld());

SelectionIntersection best;
aabb_testselect(_nullModel->localAABB(), test, best);

if (best.isValid())
{
selector.addIntersection(best);
}
}

void NullModelNode::renderHighlights(IRenderableCollector& collector, const VolumeTest& volume)
Expand Down
4 changes: 3 additions & 1 deletion radiantcore/model/NullModelNode.h
Expand Up @@ -3,10 +3,12 @@
#include "Bounded.h"
#include "irenderable.h"

#include "scene/Node.h"
#include "NullModel.h"
#include "render/RenderableBox.h"

namespace model {
namespace model
{

class NullModelNode;
typedef std::shared_ptr<NullModelNode> NullModelNodePtr;
Expand Down

0 comments on commit 8601fa7

Please sign in to comment.