Skip to content

Commit

Permalink
move worldpos and detachedcamera inside Camera
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Sep 25, 2023
1 parent a731f6a commit 6e03dec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/engine/render/rendergl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,6 @@ void gl_init()

VAR(wireframe, 0, 0, 1);

vec worldpos;

Camera::Camera()
{
}
Expand Down Expand Up @@ -654,12 +652,20 @@ VARP(invmouse, 0, 0, 1); //toggles inverting the mouse
FVARP(mouseaccel, 0, 0, 1000);

Camera *camera1 = nullptr;
//used in iengine.h
bool detachedcamera = false;

bool isthirdperson()
{
return player!=camera1 || detachedcamera;
return player!=camera1 || (camera1 && camera1->detached());
}

vec Camera::pos() const
{
return worldpos;
}

bool Camera::detached() const
{
return detachedcamera;
}

void Camera::fixrange()
Expand Down
6 changes: 5 additions & 1 deletion src/engine/render/rendergl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
extern int xtraverts, xtravertsva;
extern int renderw();
extern int renderh();
extern vec worldpos;
extern bool hasFBMSBS, hasTQ, hasDBT, hasES3, hasCI;
extern int glversion, glslversion;
extern int mesa_swap_bug;
Expand All @@ -24,8 +23,13 @@ class Camera : public dynent
vec right() const;
vec up() const;
void modifyorient(float yawdelta, float pitchdelta);
vec pos() const;
bool detached() const;
private:
void fixrange();
//used in iengine.h
bool detachedcamera = false;
vec worldpos;
};

extern Camera *camera1;
Expand Down

0 comments on commit 6e03dec

Please sign in to comment.