Skip to content

Commit

Permalink
#5912: Rename ArbitraryMeshVertex to MeshVertex. Leave an alias in th…
Browse files Browse the repository at this point in the history
…e python interface.
  • Loading branch information
codereader committed Mar 5, 2022
1 parent 34100c9 commit ab413fd
Show file tree
Hide file tree
Showing 65 changed files with 359 additions and 356 deletions.
6 changes: 3 additions & 3 deletions include/igeometryrenderer.h
Expand Up @@ -4,7 +4,7 @@
#include <limits>
#include <cstdint>
#include "igeometrystore.h"
#include "render/ArbitraryMeshVertex.h"
#include "render/MeshVertex.h"
#include "math/Matrix4.h"
#include "math/AABB.h"

Expand Down Expand Up @@ -39,15 +39,15 @@ class IGeometryRenderer
// Returns the handle which can be used to update or deallocate the data later
// The indexType determines the primitive GLenum that is chosen to render this surface
virtual Slot addGeometry(GeometryType indexType,
const std::vector<ArbitraryMeshVertex>& vertices,
const std::vector<MeshVertex>& vertices,
const std::vector<unsigned int>& indices) = 0;

// Releases a previously allocated slot. This invalidates the handle.
virtual void removeGeometry(Slot slot) = 0;

// Updates the vertex data. The size of the vertex and index array must be the same
// as the one passed to addGeometry. To change the size the data needs to be removed and re-added.
virtual void updateGeometry(Slot slot, const std::vector<ArbitraryMeshVertex>& vertices,
virtual void updateGeometry(Slot slot, const std::vector<MeshVertex>& vertices,
const std::vector<unsigned int>& indices) = 0;

// Submits the geometry of a single slot to GL
Expand Down
8 changes: 4 additions & 4 deletions include/igeometrystore.h
Expand Up @@ -3,7 +3,7 @@
#include <cstdint>
#include <vector>
#include "math/AABB.h"
#include "render/ArbitraryMeshVertex.h"
#include "render/MeshVertex.h"

namespace render
{
Expand Down Expand Up @@ -42,15 +42,15 @@ class IGeometryStore
* index arrays must not be larger than what has been allocated earlier,
* but they're allowed to be smaller.
*/
virtual void updateData(Slot slot, const std::vector<ArbitraryMeshVertex>& vertices,
virtual void updateData(Slot slot, const std::vector<MeshVertex>& vertices,
const std::vector<unsigned int>& indices) = 0;

/**
* Load a chunk of vertex and index data into the specified range, starting
* from vertexOffset/indexOffset respectively. The affected range must not be out of bounds
* of the allocated slot.
*/
virtual void updateSubData(Slot slot, std::size_t vertexOffset, const std::vector<ArbitraryMeshVertex>& vertices,
virtual void updateSubData(Slot slot, std::size_t vertexOffset, const std::vector<MeshVertex>& vertices,
std::size_t indexOffset, const std::vector<unsigned int>& indices) = 0;

/**
Expand All @@ -63,7 +63,7 @@ class IGeometryStore
// The render parameters suitable for rendering surfaces using gl(Multi)DrawElements
struct RenderParameters
{
ArbitraryMeshVertex* bufferStart; // start of buffer (to pass to gl*Pointer)
MeshVertex* bufferStart; // start of buffer (to pass to gl*Pointer)
unsigned int* firstIndex; // first index location of the given geometry
std::size_t indexCount; // index count of the given geometry
std::size_t firstVertex; // offset to the first vertex of this surface
Expand Down
12 changes: 6 additions & 6 deletions include/imodelsurface.h
@@ -1,17 +1,17 @@
#pragma once

// Math/Vertex classes
#include "render/ArbitraryMeshVertex.h"
#include "render/MeshVertex.h"

namespace model
{

// A Polygon (Triangle) which is part of a model surface
struct ModelPolygon
{
ArbitraryMeshVertex a;
ArbitraryMeshVertex b;
ArbitraryMeshVertex c;
MeshVertex a;
MeshVertex b;
MeshVertex c;
};

// Abstract definition of a model surface
Expand All @@ -25,7 +25,7 @@ class IModelSurface
virtual int getNumTriangles() const = 0;

// Get a specific vertex of this surface
virtual const ArbitraryMeshVertex& getVertex(int vertexNum) const = 0;
virtual const MeshVertex& getVertex(int vertexNum) const = 0;

/**
* greebo: Returns a specific polygon from this model surface.
Expand Down Expand Up @@ -61,7 +61,7 @@ class IIndexedModelSurface :
{
public:
// Const access to the vertices used in this surface.
virtual const std::vector<ArbitraryMeshVertex>& getVertexArray() const = 0;
virtual const std::vector<MeshVertex>& getVertexArray() const = 0;

// Const access to the index array connecting the vertices.
virtual const std::vector<unsigned int>& getIndexArray() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/irender.h
Expand Up @@ -13,7 +13,7 @@
#include "math/Vector4.h"
#include "render/Colour4.h"
#include "math/AABB.h"
#include "render/ArbitraryMeshVertex.h"
#include "render/MeshVertex.h"

#include "ishaderlayer.h"
#include <sigc++/signal.h>
Expand Down
2 changes: 1 addition & 1 deletion include/irenderable.h
Expand Up @@ -3,7 +3,7 @@
#include <memory>
#include "math/Vector3.h"

class ArbitraryMeshVertex;
class MeshVertex;
class Shader;
typedef std::shared_ptr<Shader> ShaderPtr;

Expand Down
4 changes: 2 additions & 2 deletions include/isurfacerenderer.h
Expand Up @@ -6,7 +6,7 @@
#include <vector>
#include <limits>
#include <cstdint>
#include "render/ArbitraryMeshVertex.h"
#include "render/MeshVertex.h"
#include "math/Matrix4.h"

namespace render
Expand All @@ -27,7 +27,7 @@ class IRenderableSurface :
virtual ~IRenderableSurface() {}

// Returns the vertex array of this surface
virtual const std::vector<ArbitraryMeshVertex>& getVertices() = 0;
virtual const std::vector<MeshVertex>& getVertices() = 0;

// Returns the indices to render the triangle primitives
virtual const std::vector<unsigned int>& getIndices() = 0;
Expand Down
6 changes: 3 additions & 3 deletions include/iwindingrenderer.h
Expand Up @@ -3,7 +3,7 @@
#include <vector>
#include <limits>
#include <cstdint>
#include "render/ArbitraryMeshVertex.h"
#include "render/MeshVertex.h"

class IRenderEntity;

Expand Down Expand Up @@ -33,14 +33,14 @@ class IWindingRenderer
// The winding will be associated to the given render entity (causing it to be grouped internally
// by the render entities when the surfaces are processed in lit render views).
// Returns the handle which can be used to update or deallocate the data later
virtual Slot addWinding(const std::vector<ArbitraryMeshVertex>& vertices, IRenderEntity* entity) = 0;
virtual Slot addWinding(const std::vector<MeshVertex>& vertices, IRenderEntity* entity) = 0;

// Releases a previously allocated winding slot. This invalidates the handle.
virtual void removeWinding(Slot slot) = 0;

// Updates the winding data. An IRenderEntity change is not supported through updateWinding(), in case the
// winding has to be associated to a different entity, call removeWinding() first.
virtual void updateWinding(Slot slot, const std::vector<ArbitraryMeshVertex>& vertices) = 0;
virtual void updateWinding(Slot slot, const std::vector<MeshVertex>& vertices) = 0;

// Mode used to specify how to render a single winding
enum class RenderMode
Expand Down
6 changes: 3 additions & 3 deletions libs/render.h
Expand Up @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/// \file
/// \brief High-level constructs for efficient OpenGL rendering.

#include "render/ArbitraryMeshVertex.h"
#include "render/MeshVertex.h"
#include "render/Vertex3f.h"
#include "render/TexCoord2f.h"
#include "render/VertexCb.h"
Expand Down Expand Up @@ -291,9 +291,9 @@ struct RemappingTraits<VertexCb>
};

template<>
struct RemappingTraits<ArbitraryMeshVertex>
struct RemappingTraits<MeshVertex>
{
static Vertex3f& getVertex(ArbitraryMeshVertex& container) { return container.vertex; }
static Vertex3f& getVertex(MeshVertex& container) { return container.vertex; }
};

class RemapXYZ
Expand Down
60 changes: 30 additions & 30 deletions libs/render/ArbitraryMeshVertex.h → libs/render/MeshVertex.h
Expand Up @@ -11,7 +11,7 @@
/**
* Data structure representing a mesh vertex.
*/
class ArbitraryMeshVertex
class MeshVertex
{
public:
TexCoord2f texcoord;
Expand All @@ -24,24 +24,24 @@ class ArbitraryMeshVertex
Vector4 colour;

/// Default constructor.
ArbitraryMeshVertex()
MeshVertex()
: tangent(0, 0, 0),
bitangent(0, 0, 0),
colour(1.0, 1.0, 1.0, 1.0)
{}

/// Initialising constructor, leaves colour at 1,1,1,1 and tangent vectors at 0,0,0
ArbitraryMeshVertex(const Vertex3f& v, const Normal3f& n, const TexCoord2f& t) :
ArbitraryMeshVertex(v, n, t, { 1.0, 1.0, 1.0, 1.0 })
MeshVertex(const Vertex3f& v, const Normal3f& n, const TexCoord2f& t) :
MeshVertex(v, n, t, { 1.0, 1.0, 1.0, 1.0 })
{}

/// Initialising constructor, leaves tangent vectors at 0,0,0
ArbitraryMeshVertex(const Vertex3f& v, const Normal3f& n, const TexCoord2f& t, const Vector4& c) :
ArbitraryMeshVertex(v, n, t, c, { 0, 0, 0 }, { 0, 0, 0 })
MeshVertex(const Vertex3f& v, const Normal3f& n, const TexCoord2f& t, const Vector4& c) :
MeshVertex(v, n, t, c, { 0, 0, 0 }, { 0, 0, 0 })
{}

// Initialises all attributes of this vertex
ArbitraryMeshVertex(const Vertex3f& vertex_, const Normal3f& normal_,
MeshVertex(const Vertex3f& vertex_, const Normal3f& normal_,
const TexCoord2f& texcoord_, const Vector4& colour_,
const Normal3f& tangent_, const Normal3f& bitangent_) :
texcoord(texcoord_),
Expand All @@ -59,9 +59,9 @@ class ArbitraryMeshVertex
}
};

/// Less-than comparison for ArbitraryMeshVertex
inline bool operator<(const ArbitraryMeshVertex& first,
const ArbitraryMeshVertex& other)
/// Less-than comparison for MeshVertex
inline bool operator<(const MeshVertex& first,
const MeshVertex& other)
{
if (first.texcoord != other.texcoord)
{
Expand All @@ -81,75 +81,75 @@ inline bool operator<(const ArbitraryMeshVertex& first,
return false;
}

/// Equality comparison for ArbitraryMeshVertex
inline bool operator==(const ArbitraryMeshVertex& first,
const ArbitraryMeshVertex& other)
/// Equality comparison for MeshVertex
inline bool operator==(const MeshVertex& first,
const MeshVertex& other)
{
return first.texcoord == other.texcoord
&& first.normal == other.normal
&& first.vertex == other.vertex;
}

/// Inequality comparison for ArbitraryMeshVertex
inline bool operator!=(const ArbitraryMeshVertex& first,
const ArbitraryMeshVertex& other)
/// Inequality comparison for MeshVertex
inline bool operator!=(const MeshVertex& first,
const MeshVertex& other)
{
return !(first == other);
}

namespace render
{

/// VertexTraits specialisation for ArbitraryMeshVertex
template<> class VertexTraits<ArbitraryMeshVertex>
/// VertexTraits specialisation for MeshVertex
template<> class VertexTraits<MeshVertex>
{
public:
static const void* VERTEX_OFFSET()
{
return reinterpret_cast<const void*>(
offsetof(ArbitraryMeshVertex, vertex)
offsetof(MeshVertex, vertex)
);
}

static bool hasNormal() { return true; }
static const void* NORMAL_OFFSET()
{
return reinterpret_cast<const void*>(
offsetof(ArbitraryMeshVertex, normal)
offsetof(MeshVertex, normal)
);
}

static bool hasTexCoord() { return true; }
static const void* TEXCOORD_OFFSET()
{
return reinterpret_cast<const void*>(
offsetof(ArbitraryMeshVertex, texcoord)
offsetof(MeshVertex, texcoord)
);
}

static bool hasTangents() { return true; }
static const void* TANGENT_OFFSET()
{
return reinterpret_cast<const void*>(
offsetof(ArbitraryMeshVertex, tangent)
offsetof(MeshVertex, tangent)
);
}
static const void* BITANGENT_OFFSET()
{
return reinterpret_cast<const void*>(
offsetof(ArbitraryMeshVertex, bitangent)
offsetof(MeshVertex, bitangent)
);
}
};

}

/**
* String output for ArbitraryMeshVertex.
* String output for MeshVertex.
*/
inline std::ostream& operator<< (std::ostream& os, const ArbitraryMeshVertex& v)
inline std::ostream& operator<< (std::ostream& os, const MeshVertex& v)
{
os << "ArbitraryMeshVertex { "
os << "MeshVertex { "
<< " vertex = " << v.vertex << ", normal = " << v.normal
<< ", texcoord = " << v.texcoord << ", colour = " << v.colour
<< " }";
Expand All @@ -158,8 +158,8 @@ inline std::ostream& operator<< (std::ostream& os, const ArbitraryMeshVertex& v)
}

/// \brief Calculates the tangent vectors for a triangle \p a, \p b, \p c and stores the tangent in \p s and the bitangent in \p t.
inline void ArbitraryMeshTriangle_calcTangents(const ArbitraryMeshVertex& a,
const ArbitraryMeshVertex& b, const ArbitraryMeshVertex& c,
inline void MeshTriangle_calcTangents(const MeshVertex& a,
const MeshVertex& b, const MeshVertex& c,
Vector3& s, Vector3& t)
{
s = Vector3(0, 0, 0);
Expand Down Expand Up @@ -215,11 +215,11 @@ inline void ArbitraryMeshTriangle_calcTangents(const ArbitraryMeshVertex& a,
}
}

inline void ArbitraryMeshTriangle_sumTangents(ArbitraryMeshVertex& a, ArbitraryMeshVertex& b, ArbitraryMeshVertex& c)
inline void MeshTriangle_sumTangents(MeshVertex& a, MeshVertex& b, MeshVertex& c)
{
Vector3 s, t;

ArbitraryMeshTriangle_calcTangents(a, b, c, s, t);
MeshTriangle_calcTangents(a, b, c, s, t);

a.tangent += s;
b.tangent += s;
Expand Down
2 changes: 1 addition & 1 deletion libs/render/RenderableBoundingBoxes.h
Expand Up @@ -41,7 +41,7 @@ class RenderableBoundingBoxes :

_needsUpdate = false;

std::vector<ArbitraryMeshVertex> vertices;
std::vector<MeshVertex> vertices;
std::vector<unsigned int> indices;

static auto WireframeBoxIndices = render::detail::generateWireframeBoxIndices();
Expand Down

0 comments on commit ab413fd

Please sign in to comment.