Skip to content

Commit

Permalink
Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
sturnclaw committed Nov 22, 2023
1 parent f9da4b8 commit c5cf33e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 28 deletions.
10 changes: 6 additions & 4 deletions src/Aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ struct Aabb {
min(DBL_MAX, DBL_MAX, DBL_MAX),
max(-DBL_MAX, -DBL_MAX, -DBL_MAX),
radius(0.1)
{}
{
}
// Fast constructor for pre-conditioned values
// Should only be used when _min < _max for all {x,y,z}
Aabb(const vector3d &_min, const vector3d &_max, float rad) :
min(_min),
max(_max),
radius(rad)
{}
{
}
void Update(const Aabb &b)
{
max.x = std::max(max.x, b.max.x);
Expand Down Expand Up @@ -69,7 +71,7 @@ struct Aabb {
};

// SIMD-capable AABB type without additional overhead
template<typename Vec3>
template <typename Vec3>
struct AABB {
using Number = typename Vec3::element_type;

Expand Down Expand Up @@ -100,8 +102,8 @@ struct AABB {

auto IntersectsRay(const Vec3 &start, const Vec3 &inv_dir, Number dist) const
{
using std::min;
using std::max;
using std::min;

Vec3 l1 = (this->min - start) * inv_dir;
Vec3 l2 = (this->max - start) * inv_dir;
Expand Down
3 changes: 2 additions & 1 deletion src/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ class Frame {
struct Dummy {
Dummy() :
madeWithFactory(false)
{}
{
}
bool madeWithFactory;
};

Expand Down
2 changes: 1 addition & 1 deletion src/collider/CollisionSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void CollisionSpace::RebuildBVHTree(SingleBVHTree *tree, uint32_t numGeoms, cons
vector3d pos = geom->GetPosition();
double radius = geom->GetGeomTree()->GetRadius();

AABBd aabb { {pos - radius }, { pos + radius } };
AABBd aabb{ { pos - radius }, { pos + radius } };

aabbs.push_back(aabb);
bounds.Update(aabb);
Expand Down
4 changes: 2 additions & 2 deletions src/collider/CollisionSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#ifndef _COLLISION_SPACE
#define _COLLISION_SPACE

#include "../vector3.h"
#include "../Aabb.h"
#include "../vector3.h"

#include <vector>
#include <memory>
#include <vector>

class Geom;
class SingleBVHTree;
Expand Down
1 change: 1 addition & 0 deletions src/collider/Geom.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Geom {
vector3d m_pos;
const GeomTree *m_geomtree;
matrix4x4d m_orient, m_invOrient;

public:
matrix4x4d m_animTransform;

Expand Down
10 changes: 5 additions & 5 deletions src/graphics/Drawables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,12 +876,12 @@ namespace Graphics {
Graphics::VertexArray va = Graphics::VertexArray(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_UV0);

// Generate two triangles for the grid plane
va.Add(vector3f( grid_size.x, 0, -grid_size.y), vector2f( grid_size.x, -grid_size.y));
va.Add(vector3f(-grid_size.x, 0, grid_size.y), vector2f(-grid_size.x, grid_size.y));
va.Add(vector3f(grid_size.x, 0, -grid_size.y), vector2f(grid_size.x, -grid_size.y));
va.Add(vector3f(-grid_size.x, 0, grid_size.y), vector2f(-grid_size.x, grid_size.y));
va.Add(vector3f(-grid_size.x, 0, -grid_size.y), vector2f(-grid_size.x, -grid_size.y));
va.Add(vector3f( grid_size.x, 0, -grid_size.y), vector2f( grid_size.x, -grid_size.y));
va.Add(vector3f( grid_size.x, 0, grid_size.y), vector2f( grid_size.x, grid_size.y));
va.Add(vector3f(-grid_size.x, 0, grid_size.y), vector2f(-grid_size.x, grid_size.y));
va.Add(vector3f(grid_size.x, 0, -grid_size.y), vector2f(grid_size.x, -grid_size.y));
va.Add(vector3f(grid_size.x, 0, grid_size.y), vector2f(grid_size.x, grid_size.y));
va.Add(vector3f(-grid_size.x, 0, grid_size.y), vector2f(-grid_size.x, grid_size.y));

GridData data = {};
data.thin_color = m_minorColor.ToColor4f();
Expand Down
2 changes: 1 addition & 1 deletion src/scenegraph/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "scenegraph/Animation.h"
#include "scenegraph/Label3D.h"
#include "scenegraph/MatrixTransform.h"
#include "scenegraph/Tag.h"
#include "scenegraph/NodeVisitor.h"
#include "scenegraph/StaticGeometry.h"
#include "scenegraph/Tag.h"
#include "utils.h"

namespace SceneGraph {
Expand Down
40 changes: 26 additions & 14 deletions src/vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,84 +227,96 @@ inline vector3<float>::vector3(const vector2f &v, float t) :
x(v.x),
y(v.y),
z(t)
{}
{
}
template <>
inline vector3<float>::vector3(const vector3<double> &v) :
x(float(v.x)),
y(float(v.y)),
z(float(v.z))
{}
{
}
template <>
inline vector3<double>::vector3(const vector3<float> &v) :
x(v.x),
y(v.y),
z(v.z)
{}
{
}
template <>
inline vector3<double>::vector3(const vector2f &v, double t) :
x(v.x),
y(v.y),
z(t)
{}
{
}
template <>
inline vector3<float>::vector3(float val) :
x(val),
y(val),
z(val)
{}
{
}
template <>
inline vector3<double>::vector3(double val) :
x(val),
y(val),
z(val)
{}
{
}
template <>
inline vector3<float>::vector3(float _x, float _y, float _z) :
x(_x),
y(_y),
z(_z)
{}
{
}
template <>
inline vector3<double>::vector3(double _x, double _y, double _z) :
x(_x),
y(_y),
z(_z)
{}
{
}
template <>
inline vector3<float>::vector3(const float vals[3]) :
x(vals[0]),
y(vals[1]),
z(vals[2])
{}
{
}
template <>
inline vector3<float>::vector3(const double vals[3]) :
x(float(vals[0])),
y(float(vals[1])),
z(float(vals[2]))
{}
{
}
template <>
inline vector3<double>::vector3(const float vals[3]) :
x(vals[0]),
y(vals[1]),
z(vals[2])
{}
{
}
template <>
inline vector3<double>::vector3(const double vals[3]) :
x(vals[0]),
y(vals[1]),
z(vals[2])
{}
{
}

// max() overload for use with C++ ADL
template<typename T>
template <typename T>
vector3<T> max(const vector3<T> &lhs, const vector3<T> &rhs)
{
using std::max; // support max(T) overloads
return vector3<T>(max(lhs.x, rhs.x), max(lhs.y, rhs.y), max(lhs.z, rhs.z));
}

// min() overload for use with C++ ADL
template<typename T>
template <typename T>
vector3<T> min(const vector3<T> &lhs, const vector3<T> &rhs)
{
using std::min; // support min(T) overloads
Expand Down

0 comments on commit c5cf33e

Please sign in to comment.