Skip to content

Commit

Permalink
#5231: Working on getting the Texture Tool to compile. More classes m…
Browse files Browse the repository at this point in the history
…oved to libs.
  • Loading branch information
codereader committed Jun 11, 2020
1 parent f9e706e commit 26a84ee
Show file tree
Hide file tree
Showing 67 changed files with 811 additions and 728 deletions.
9 changes: 8 additions & 1 deletion include/ibrush.h
Expand Up @@ -5,9 +5,9 @@

#include "math/Vector2.h"
#include "math/Vector3.h"
#include "math/Matrix4.h"
#include <vector>

class Matrix4;
class Plane3;

const std::string RKEY_ENABLE_TEXTURE_LOCK("user/ui/brush/textureLock");
Expand Down Expand Up @@ -129,6 +129,13 @@ class IFace
* tx and ty hold the shift
*/
virtual Matrix4 getTexDefMatrix() const = 0;

/**
* The matrix used to project world coordinates to U/V space.
*/
virtual Matrix4 getProjectionMatrix() = 0;

virtual void setProjectionMatrix(const Matrix4& projection) = 0;
};

// Plane classification info used by splitting and CSG algorithms
Expand Down
6 changes: 6 additions & 0 deletions include/imap.h
Expand Up @@ -132,6 +132,12 @@ class IMap :
* Returns the name of the map.
*/
virtual std::string getMapName() const = 0;

// Returns true if the map has unsaved changes.
virtual bool isModified() const = 0;

// Sets the modified status of this map
virtual void setModified(bool modifiedFlag) = 0;
};
typedef std::shared_ptr<IMap> IMapPtr;

Expand Down
16 changes: 16 additions & 0 deletions include/ipatch.h
Expand Up @@ -42,6 +42,17 @@ struct PatchMesh
std::vector<VertexNT> vertices;
};

struct PatchRenderIndices
{
// The indices, arranged in the way it's expected by GL_QUAD_STRIPS
// The number of indices is (lenStrips*numStrips)
std::vector<unsigned int> indices;

// Strip index layout
std::size_t numStrips;
std::size_t lenStrips;
};

typedef BasicVector2<unsigned int> Subdivisions;

// The abstract base class for a Doom3-compatible patch
Expand Down Expand Up @@ -90,6 +101,9 @@ class IPatch
// Returns a copy of the fully tesselated patch geometry (slow!)
virtual PatchMesh getTesselatedPatchMesh() const = 0;

// Returns a copy of the render indices which can be passed to GL_QUAD_STRIPS (slow)
virtual PatchRenderIndices getRenderIndices() const = 0;

/**
* greebo: Inserts two columns before and after the column with index <colIndex>.
* Throws an GenericPatchException if an error occurs.
Expand Down Expand Up @@ -144,6 +158,8 @@ class IPatch
* @divisions: a two-component vector containing the desired subdivisions
*/
virtual void setFixedSubdivisions(bool isFixed, const Subdivisions& divisions) = 0;

virtual void undoSave() = 0;
};

namespace patch
Expand Down
4 changes: 3 additions & 1 deletion include/iselection.h
Expand Up @@ -32,6 +32,7 @@ typedef sigc::slot<void, const ISelectable&> SelectionChangedSlot;

class SelectionInfo;
class Face;
class IFace;
class Brush;
class Patch;

Expand Down Expand Up @@ -264,7 +265,7 @@ class SelectionSystem :
* Singly selected faces (those which have been selected in component mode) are
* considered as well by this method.
*/
virtual void foreachFace(const std::function<void(Face&)>& functor) = 0;
virtual void foreachFace(const std::function<void(IFace&)>& functor) = 0;

/**
* Call the given functor for each selected patch. Selected group nodes like func_statics
Expand All @@ -282,6 +283,7 @@ class SelectionSystem :
virtual void onManipulationStart() = 0;
virtual void onManipulationChanged() = 0;
virtual void onManipulationEnd() = 0;
virtual void onManipulationCancelled() = 0;

// Deprecated
virtual void SelectPoint(const render::View& view, const Vector2& devicePoint, const Vector2& deviceEpsilon, EModifier modifier, bool face) = 0;
Expand Down
39 changes: 23 additions & 16 deletions radiantcore/map/EntityBreakdown.h → libs/scene/EntityBreakdown.h
@@ -1,13 +1,13 @@
#ifndef ENTITYBREAKDOWN_H_
#define ENTITYBREAKDOWN_H_
#pragma once

#include <map>
#include <string>
#include "iscenegraph.h"
#include "ientity.h"
#include "ieclass.h"

namespace map {
namespace scene
{

/** greebo: This object traverses the scenegraph on construction
* counting all occurrences of each entity class.
Expand All @@ -22,25 +22,31 @@ class EntityBreakdown :
Map _map;

public:
EntityBreakdown() {
EntityBreakdown()
{
_map.clear();
GlobalSceneGraph().root()->traverse(*this);
}

bool pre(const scene::INodePtr& node) {
bool pre(const scene::INodePtr& node) override
{
// Is this node an entity?
Entity* entity = Node_getEntity(node);

if (entity != NULL) {
if (entity != nullptr)
{
IEntityClassConstPtr eclass = entity->getEntityClass();
std::string ecName = eclass->getName();

Map::iterator found = _map.find(ecName);
if (found == _map.end()) {
auto found = _map.find(ecName);

if (found == _map.end())
{
// Entity class not yet registered, create new entry
_map.insert(Map::value_type(ecName, 1));
_map.emplace(ecName, 1);
}
else {
else
{
// Eclass is known, increase the counter
found->second++;
}
Expand All @@ -50,20 +56,21 @@ class EntityBreakdown :
}

// Accessor method to retrieve the entity breakdown map
Map getMap() {
const Map& getMap() const
{
return _map;
}

Map::const_iterator begin() const {
Map::const_iterator begin() const
{
return _map.begin();
}

Map::const_iterator end() const {
Map::const_iterator end() const
{
return _map.end();
}

}; // class EntityBreakdown

} // namespace map

#endif /*ENTITYBREAKDOWN_H_*/
} // namespace
56 changes: 29 additions & 27 deletions radiantcore/map/ModelBreakdown.h → libs/scene/ModelBreakdown.h
@@ -1,13 +1,13 @@
#ifndef MODELBREAKDOWN_H_
#define MODELBREAKDOWN_H_
#pragma once

#include <map>
#include <string>
#include "iscenegraph.h"
#include "imodel.h"
#include "modelskin.h"

namespace map {
namespace scene
{

/**
* greebo: This object traverses the scenegraph on construction
Expand Down Expand Up @@ -37,25 +37,27 @@ class ModelBreakdown :
mutable Map _map;

public:
ModelBreakdown() {
ModelBreakdown()
{
_map.clear();
GlobalSceneGraph().root()->traverseChildren(*this);
}

bool pre(const scene::INodePtr& node) {
bool pre(const scene::INodePtr& node) override
{
// Check if this node is a model
model::ModelNodePtr modelNode = Node_getModel(node);

if (modelNode != NULL) {
if (modelNode)
{
// Get the actual model from the node
const model::IModel& model = modelNode->getIModel();

Map::iterator found = _map.find(model.getModelPath());

if (found == _map.end()) {
std::pair<Map::iterator, bool> result = _map.insert(
Map::value_type(model.getModelPath(), ModelCount())
);
if (found == _map.end())
{
auto result = _map.emplace(model.getModelPath(), ModelCount());

found = result.first;

Expand All @@ -71,16 +73,17 @@ class ModelBreakdown :
modelCount.count++;

// Increase the skin count, check if we have a skinnable model
SkinnedModelPtr skinned = std::dynamic_pointer_cast<SkinnedModel>(node);
auto skinned = std::dynamic_pointer_cast<SkinnedModel>(node);

if (skinned != NULL) {
if (skinned)
{
std::string skinName = skinned->getSkin();

ModelCount::SkinCountMap::iterator foundSkin = modelCount.skinCount.find(skinName);
auto foundSkin = modelCount.skinCount.find(skinName);

if (foundSkin == modelCount.skinCount.end()) {
std::pair<ModelCount::SkinCountMap::iterator, bool> result =
modelCount.skinCount.insert(ModelCount::SkinCountMap::value_type(skinName, 0));
if (foundSkin == modelCount.skinCount.end())
{
auto result = modelCount.skinCount.emplace(skinName, 0);

foundSkin = result.first;
}
Expand All @@ -93,7 +96,8 @@ class ModelBreakdown :
}

// Accessor method to retrieve the entity breakdown map
const Map& getMap() const {
const Map& getMap() const
{
return _map;
}

Expand All @@ -102,10 +106,9 @@ class ModelBreakdown :
std::set<std::string> skinMap;

// Determine the number of distinct skins
for (Map::const_iterator m = _map.begin(); m != _map.end(); ++m)
for (auto m = _map.begin(); m != _map.end(); ++m)
{
for (ModelCount::SkinCountMap::const_iterator s = m->second.skinCount.begin();
s != m->second.skinCount.end(); ++s)
for (auto s = m->second.skinCount.begin(); s != m->second.skinCount.end(); ++s)
{
if (!s->first.empty())
{
Expand All @@ -117,16 +120,15 @@ class ModelBreakdown :
return skinMap.size();
}

Map::const_iterator begin() const {
Map::const_iterator begin() const
{
return _map.begin();
}

Map::const_iterator end() const {
Map::const_iterator end() const
{
return _map.end();
}
};

}; // class ModelBreakdown

} // namespace map

#endif /* MODELBREAKDOWN_H_ */
} // namespace

0 comments on commit 26a84ee

Please sign in to comment.