Skip to content

Commit

Permalink
Backend update from GZDoom.
Browse files Browse the repository at this point in the history
Mostly missing headers
  • Loading branch information
coelckers committed Feb 24, 2024
1 parent c769de1 commit b383a99
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 21 deletions.
1 change: 1 addition & 0 deletions source/common/engine/palettecontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
**
*/

#include <cmath>
#include "palutil.h"
#include "sc_man.h"
#include "m_crc32.h"
Expand Down
30 changes: 30 additions & 0 deletions source/common/engine/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "textures.h"
#include "texturemanager.h"
#include "base64.h"
#include "vm.h"
#include "i_interface.h"

using namespace FileSys;
Expand Down Expand Up @@ -1591,6 +1592,35 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary
}
}

template<> FSerializer& Serialize(FSerializer& arc, const char* key, VMFunction*& func, VMFunction**)
{
if (arc.isWriting())
{
arc.WriteKey(key);
if (func) arc.w->String(func->QualifiedName);
else arc.w->Null();
}
else
{
func = nullptr;

auto val = arc.r->FindKey(key);
if (val != nullptr && val->IsString())
{
auto qname = val->GetString();
size_t p = strcspn(qname, ".");
if (p != 0)
{
FName clsname(qname, p, true);
FName funcname(qname + p + 1, true);
func = PClass::FindFunction(clsname, funcname);
}
}

}
return arc;
}

//==========================================================================
//
// Handler to retrieve a numeric value of any kind.
Expand Down
1 change: 1 addition & 0 deletions source/common/engine/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ inline FSerializer& Serialize(FSerializer& arc, const char* key, BitArray& value
template<> FSerializer& Serialize(FSerializer& arc, const char* key, PClass*& clst, PClass** def);
template<> FSerializer& Serialize(FSerializer& arc, const char* key, FFont*& font, FFont** def);
template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary *&dict, Dictionary **def);
template<> FSerializer& Serialize(FSerializer& arc, const char* key, VMFunction*& dict, VMFunction** def);

inline FSerializer &Serialize(FSerializer &arc, const char *key, DVector3 &p, DVector3 *def)
{
Expand Down
1 change: 1 addition & 0 deletions source/common/objects/autosegs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
** compile with something other than Visual C++ or GCC.
*/

#include <cassert>
#include "autosegs.h"

#ifdef _WIN32
Expand Down
1 change: 1 addition & 0 deletions source/common/objects/autosegs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#define AUTOSEGS_H

#include <type_traits>
#include <cstdint>

#if defined(__clang__)
#if defined(__has_feature) && __has_feature(address_sanitizer)
Expand Down
4 changes: 3 additions & 1 deletion source/common/platform/posix/sdl/i_joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ class SDLInputJoystick: public IJoystickConfig

friend class SDLInputJoystickManager;
};
const EJoyAxis SDLInputJoystick::DefaultAxes[5] = {JOYAXIS_Side, JOYAXIS_Forward, JOYAXIS_Pitch, JOYAXIS_Yaw, JOYAXIS_Up};

// [Nash 4 Feb 2024] seems like on Linux, the third axis is actually the Left Trigger, resulting in the player uncontrollably looking upwards.
const EJoyAxis SDLInputJoystick::DefaultAxes[5] = {JOYAXIS_Side, JOYAXIS_Forward, JOYAXIS_None, JOYAXIS_Yaw, JOYAXIS_Pitch};

class SDLInputJoystickManager
{
Expand Down
20 changes: 2 additions & 18 deletions source/common/rendering/hwrenderer/data/hw_vrmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,11 @@ float VREyeInfo::getShift() const
return vr_swap_eyes ? -res : res;
}

VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio, bool iso_ortho) const
VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio) const
{
VSMatrix result;

if (iso_ortho) // Orthographic projection for isometric viewpoint
{
double zNear = -1.0; // screen->GetZNear();
double zFar = screen->GetZFar();

double fH = tan(DEG2RAD(fov) / 2) / fovRatio;
double fW = fH * aspectRatio * mScaleFactor;
double left = -fW;
double right = fW;
double bottom = -fH;
double top = fH;

VSMatrix fmat(1);
fmat.ortho((float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar);
return fmat;
}
else if (mShiftFactor == 0)
if (mShiftFactor == 0)
{
float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)));
result.perspective(fovy, aspectRatio, screen->GetZNear(), screen->GetZFar());
Expand Down
2 changes: 1 addition & 1 deletion source/common/rendering/hwrenderer/data/hw_vrmodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct VREyeInfo
float mShiftFactor;
float mScaleFactor;

VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio, bool iso_ortho) const;
VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const;
DVector3 GetViewShift(float yaw) const;
private:
float getShift() const;
Expand Down
1 change: 1 addition & 0 deletions source/common/textures/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#ifndef __BITMAP_H__
#define __BITMAP_H__

#include <cstring>
#include "palentry.h"

struct FCopyInfo;
Expand Down
2 changes: 2 additions & 0 deletions source/common/thirdparty/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef MD5_H
#define MD5_H

#include <cstdint>

struct MD5Context
{
MD5Context() { Init(); }
Expand Down
3 changes: 2 additions & 1 deletion source/common/utility/engineerrors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@

bool gameisdead;

#ifdef _WIN32
#include <cstdarg>

#ifdef _WIN32
#include <windows.h>
#include "zstring.h"
void I_DebugPrint(const char *cp)
Expand Down
2 changes: 2 additions & 0 deletions source/common/utility/palette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/

#include <algorithm>
#include <cfloat>
#include <cmath>
#include "palutil.h"
#include "palentry.h"
#include "sc_man.h"
Expand Down
1 change: 1 addition & 0 deletions source/common/utility/writezip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "files.h"
#include "m_swap.h"
#include "w_zip.h"
#include "fs_decompress.h"

using FileSys::FCompressedBuffer;

Expand Down
1 change: 1 addition & 0 deletions source/common/widgets/netstartwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "netstartwindow.h"
#include "version.h"
#include "engineerrors.h"
#include "gstrings.h"
#include <zwidget/core/timer.h>
#include <zwidget/widgets/textlabel/textlabel.h>
#include <zwidget/widgets/pushbutton/pushbutton.h>
Expand Down

0 comments on commit b383a99

Please sign in to comment.