Skip to content

Commit

Permalink
use glm
Browse files Browse the repository at this point in the history
  • Loading branch information
atupone committed Jul 26, 2024
1 parent 20b2732 commit 5a46188
Show file tree
Hide file tree
Showing 260 changed files with 5,768 additions and 8,134 deletions.
4 changes: 3 additions & 1 deletion MSVC/build/ogl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\ogl\OpenGLAPI.cxx" />
<ClCompile Include="..\..\src\ogl\OpenGLFramebuffer.cxx" />
<ClCompile Include="..\..\src\ogl\OpenGLGState.cxx">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
Expand Down Expand Up @@ -279,6 +280,7 @@
<ItemGroup>
<ClInclude Include="..\..\include\bzfgl.h" />
<ClInclude Include="..\..\include\glext.h" />
<ClInclude Include="..\..\include\OpenGLAPI.h" />
<ClInclude Include="..\..\include\OpenGLFramebuffer.h" />
<ClInclude Include="..\..\include\OpenGLGState.h" />
<ClInclude Include="..\..\include\OpenGLLight.h" />
Expand All @@ -290,4 +292,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 7 additions & 1 deletion MSVC/build/ogl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<ClCompile Include="..\..\src\ogl\RenderNode.cxx">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ogl\OpenGLAPI.cxx">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ogl\OpenGLFramebuffer.cxx">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -48,6 +51,9 @@
<ClInclude Include="..\..\include\glext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\OpenGLAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\OpenGLFramebuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -60,4 +66,4 @@
<UniqueIdentifier>{8b1c786a-fe0a-4a9f-8809-6572c90a8d13}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>
4 changes: 0 additions & 4 deletions Xcode/BZFlag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,6 @@
0305D5F0166C9DAE00557FC4 /* TextUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtils.h; sourceTree = "<group>"; };
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeKeeper.h; sourceTree = "<group>"; };
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriWallSceneNode.h; sourceTree = "<group>"; };
0305D5F5166C9DAE00557FC4 /* vectors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors.h; sourceTree = "<group>"; };
0305D5F6166C9DAE00557FC4 /* vectors_old.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectors_old.h; sourceTree = "<group>"; };
0305D5F7166C9DAE00557FC4 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewFrustum.h; sourceTree = "<group>"; };
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VotingBooth.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2368,8 +2366,6 @@
0305D5F0166C9DAE00557FC4 /* TextUtils.h */,
0305D5F2166C9DAE00557FC4 /* TimeKeeper.h */,
0305D5F4166C9DAE00557FC4 /* TriWallSceneNode.h */,
0305D5F5166C9DAE00557FC4 /* vectors.h */,
0305D5F6166C9DAE00557FC4 /* vectors_old.h */,
0305D5F7166C9DAE00557FC4 /* version.h */,
0305D5F8166C9DAE00557FC4 /* ViewFrustum.h */,
0305D5FA166C9DAE00557FC4 /* VotingBooth.h */,
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ AC_CHECK_HEADERS( \
cstdio \
cstring
)
AC_CHECK_HEADERS(
[glm/glm.hpp],
,
[AC_MSG_ERROR([glm (from https://glm.g-truc.net) is needed])])
AC_LANG(C)
AC_CHECK_HEADERS( \
SDL2/SDL.h \
Expand Down
3 changes: 2 additions & 1 deletion include/AnsiCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

// System headers
#include <string>
#include <glm/vec3.hpp>

// Common headers
#include "TextUtils.h"
Expand Down Expand Up @@ -105,7 +106,7 @@ static const std::string ColorStrings[17] =
ANSI_STR_NO_UNDERLINE // 16 No Underlining
};

inline std::string rgbToAnsi(const float* color)
inline std::string rgbToAnsi(const glm::vec3 &color)
{
return TextUtils::format("%s;%u;%u;%um",
ANSI_STR_FG_RGB,
Expand Down
23 changes: 5 additions & 18 deletions include/ArcObstacle.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ArcObstacle : public Obstacle

ArcObstacle();
ArcObstacle(const MeshTransform& transform,
const float* _pos, const float* _size,
const glm::vec3 &_pos, const glm::vec3 &_size,
float _rotation, float _angle, float _ratio,
const float _texsize[4], bool _useNormals,
int _divisions, const BzMaterial* mats[MaterialCount],
Expand All @@ -63,23 +63,10 @@ class ArcObstacle : public Obstacle
bool isFlatTop() const;

float intersect(const Ray&) const;
void getNormal(const float* p, float* n) const;
void get3DNormal(const float* p, float* n) const;

bool inCylinder(const float* p, float radius, float height) const;
bool inBox(const float* p, float angle,
float halfWidth, float halfBreadth, float height) const;
bool inMovingBox(const float* oldP, float oldAngle,
const float *newP, float newAngle,
float halfWidth, float halfBreadth, float height) const;
bool isCrossing(const float* p, float angle,
float halfWidth, float halfBreadth, float height,
float* plane) const;

bool getHitNormal(const float* pos1, float azimuth1,
const float* pos2, float azimuth2,
float halfWidth, float halfBreadth,
float height, float* normal) const;
void getNormal(const glm::vec3 &p, glm::vec3 &n) const override;
void get3DNormal(const glm::vec3 &p, glm::vec3 &n) const override;

bool inCylinder(const glm::vec3 &p, float radius, float height) const override;

int packSize() const;
void *pack(void*) const;
Expand Down
3 changes: 2 additions & 1 deletion include/BSPSceneDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

// system headers
#include <vector>
#include <glm/vec3.hpp>

// common implementation headers
#include "bzfgl.h"
Expand Down Expand Up @@ -83,7 +84,7 @@ class BSPSceneDatabase : public SceneDatabase
Node* root;
int depth;
// the following members avoid passing parameters around
GLfloat eye[3];
glm::vec3 eye;
SceneRenderer* renderer;
const ViewFrustum* frustum;

Expand Down
17 changes: 9 additions & 8 deletions include/BaseBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef BZF_BASE_BUILDING_H
#define BZF_BASE_BUILDING_H

// Inherits from
#include "BoxBuilding.h"

class BaseBuilding : public BoxBuilding
Expand All @@ -26,22 +27,22 @@ class BaseBuilding : public BoxBuilding

public:
BaseBuilding();
BaseBuilding(const float *pos, float rotation,
const float *size, int _team, bool ricochet);
BaseBuilding(const glm::vec3 &pos, float rotation,
const glm::vec3 &size, int _team, bool ricochet);
~BaseBuilding();

Obstacle* copyWithTransform(const MeshTransform&) const;

const char* getType() const;
static const char* getClassName(); // const

bool inCylinder(const float* p, float radius, float height) const;
bool inMovingBox(const float* oldP, float oldAngle,
const float *newP, float newAngle,
float halfWidth, float halfBreadth, float height) const;
bool isCrossing(const float* p, float angle,
bool inCylinder(const glm::vec3 &p, float radius, float height) const override;
bool inMovingBox(const glm::vec3 &oldP, float oldAngle,
const glm::vec3 &newP, float newAngle,
float halfWidth, float halfBreadth, float height) const override;
bool isCrossing(const glm::vec3 &p, float angle,
float halfWidth, float halfBreadth, float height,
float* plane) const;
glm::vec4 *plane) const override;

int getTeam() const;

Expand Down
10 changes: 5 additions & 5 deletions include/BillboardSceneNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class BillboardSceneNode : public SceneNode
{
public:
BillboardSceneNode(const GLfloat pos[3]);
BillboardSceneNode(const glm::vec3 &pos);
~BillboardSceneNode();

virtual BillboardSceneNode* copy() const;
Expand All @@ -53,7 +53,7 @@ class BillboardSceneNode : public SceneNode
void setTexture(const int);
void setTextureAnimation(int cu, int cv);

void move(const GLfloat pos[3]);
void move(const glm::vec3 &pos);
void setAngle(GLfloat);
void addLight(SceneRenderer&);

Expand All @@ -68,7 +68,7 @@ class BillboardSceneNode : public SceneNode
~BillboardRenderNode();
void setColor(const GLfloat* rgba);
void render() override;
const GLfloat* getPosition() const override;
const glm::vec3 &getPosition() const override;
void setFrame(float u, float v);
void setFrameSize(float du, float dv);
private:
Expand All @@ -90,9 +90,9 @@ class BillboardSceneNode : public SceneNode
bool lightSource;
bool groundLight;
float width, height;
GLfloat color[4];
glm::vec4 color;
GLfloat angle;
GLfloat lightColor[3];
glm::vec3 lightColor;
GLfloat lightScale;
float lightCutoffTime;
int cu, cv;
Expand Down
49 changes: 21 additions & 28 deletions include/BoltSceneNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,31 @@
// Inherits from
#include "SceneNode.h"

// System headers
#include <glm/vec4.hpp>

// Common headers
#include "OpenGLLight.h"

class BoltSceneNode : public SceneNode
{
public:
BoltSceneNode(const GLfloat pos[3], const GLfloat vel[3], bool super);
BoltSceneNode(const glm::vec3 &pos, const glm::vec3 &vel, bool super);
~BoltSceneNode();

void setFlares(bool);
void setSize(float radius);
void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a = 1.0f);
void setTextureColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a = 1.0f);
void setColor(const GLfloat* rgb);
void setTeamColor(const GLfloat* rgb);
void setColor(const glm::vec3 &rgb);
void setTeamColor(const glm::vec3 &rgb);
void setTexture(const int);
void setTextureAnimation(int cu, int cv);

bool getColorblind() const;
void setColorblind(bool);

bool getInvisible() const
{
return invisible;
}
void setInvisible(bool _invisible)
{
invisible = _invisible;
}

void move(const GLfloat pos[3], const GLfloat forward[3]);
void move(const glm::vec3 &pos, const glm::vec3 &forward);
void addLight(SceneRenderer&);

void notifyStyleChange() override;
Expand All @@ -64,10 +58,10 @@ class BoltSceneNode : public SceneNode
public:
BoltRenderNode(const BoltSceneNode*);
~BoltRenderNode();
void setColor(const GLfloat* rgba);
void setTextureColor(const GLfloat* rgba);
void setColor(const glm::vec4 &rgba);
void setTextureColor(const glm::vec4 &rgba);
void render() override;
const GLfloat* getPosition() const override;
const glm::vec3 &getPosition() const override;
void setAnimation(int cu, int cv);

void renderGeoBolt();
Expand All @@ -78,19 +72,18 @@ class BoltSceneNode : public SceneNode
const BoltSceneNode* sceneNode;
int u, v, cu, cv;
GLfloat du, dv;
GLfloat mainColor[4];
GLfloat innerColor[4];
GLfloat outerColor[4];
GLfloat coronaColor[4];
GLfloat flareColor[4];
GLfloat textureColor[4];
glm::vec4 mainColor;
glm::vec4 innerColor;
glm::vec4 outerColor;
glm::vec4 coronaColor;
glm::vec4 flareColor;
glm::vec4 textureColor;
int numFlares;
float theta[6];
float phi[6];

static GLfloat core[9][2];
static GLfloat corona[8][2];
static const GLfloat ring[8][2];
static glm::vec2 core[9];
static const glm::vec2 corona[8];
static const GLfloat CoreFraction;
static const GLfloat FlareSize;
static const GLfloat FlareSpread;
Expand All @@ -103,9 +96,9 @@ class BoltSceneNode : public SceneNode
bool texturing;
bool colorblind;
float size;
float velocity[3];
GLfloat color[4];
fvec4 teamColor;
glm::vec4 color;
glm::vec4 teamColor;
glm::vec3 velocity;
OpenGLLight light;
OpenGLGState gstate;
OpenGLGState colorblindGState;
Expand Down
37 changes: 20 additions & 17 deletions include/BoxBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
#ifndef BZF_BOX_BUILDING_H
#define BZF_BOX_BUILDING_H

#include "common.h"
#include <string>
// Inherits from
#include "Obstacle.h"

// System headers
#include <string>
#include <glm/fwd.hpp>

class BoxBuilding : public Obstacle
{
public:
BoxBuilding();
BoxBuilding(const float* pos, float rotation,
BoxBuilding(const glm::vec3 &pos, float rotation,
float width, float breadth, float height,
bool drive = false, bool shoot = false,
bool ricochet = false, bool invisible = false);
Expand All @@ -39,28 +42,28 @@ class BoxBuilding : public Obstacle
bool isFlatTop() const;

float intersect(const Ray&) const;
void getNormal(const float* p, float* n) const;
void get3DNormal(const float* p, float* n) const;
void getNormal(const glm::vec3 &p, glm::vec3 &n) const override;
void get3DNormal(const glm::vec3 &p, glm::vec3 &n) const override;
inline bool isInvisible() const;

bool inCylinder(const float* p, float radius, float height) const;
bool inBox(const float* p, float angle,
float halfWidth, float halfBreadth, float height) const;
bool inMovingBox(const float* oldP, float oldAngle,
const float *newP, float newAngle,
float halfWidth, float halfBreadth, float height) const;
bool isCrossing(const float* p, float angle,
bool inCylinder(const glm::vec3 &p, float radius, float height) const override;
bool inBox(const glm::vec3 &p, float angle,
float halfWidth, float halfBreadth, float height) const override;
bool inMovingBox(const glm::vec3 &oldP, float oldAngle,
const glm::vec3 &newP, float newAngle,
float halfWidth, float halfBreadth, float height) const override;
bool isCrossing(const glm::vec3 &p, float angle,
float halfWidth, float halfBreadth, float height,
float* plane) const;
glm::vec4 *plane) const override;

bool getHitNormal(
const float* pos1, float azimuth1,
const float* pos2, float azimuth2,
const glm::vec3 &pos1, float azimuth1,
const glm::vec3 &pos2, float azimuth2,
float halfWidth, float halfBreadth,
float height,
float* normal) const;
glm::vec3 &normal) const override;

void getCorner(int index, float* pos) const;
void getCorner(int index, glm::vec3 &pos) const;

int packSize() const;
void *pack(void*) const;
Expand Down
Loading

0 comments on commit 5a46188

Please sign in to comment.