Index: ps/trunk/source/renderer/RenderingOptions.h
===================================================================
--- ps/trunk/source/renderer/RenderingOptions.h (revision 25902)
+++ ps/trunk/source/renderer/RenderingOptions.h (revision 25903)
@@ -1,123 +1,122 @@
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
/**
* Keeps track of the settings used for rendering.
* Ideally this header file should remain very quick to parse,
* so avoid including other headers here unless absolutely necessary.
*
* Lifetime concerns: g_RenderingOptions always exists, but hooks are tied to the configDB's lifetime
* an the renderer may or may not actually exist.
*/
#ifndef INCLUDED_RENDERINGOPTIONS
#define INCLUDED_RENDERINGOPTIONS
-class CConfigDB;
class CStr8;
class CRenderer;
enum RenderPath {
// If no rendering path is configured explicitly, the renderer
// will choose the path when Open() is called.
DEFAULT,
// Classic fixed function.
FIXED,
// Use new ARB/GLSL system
SHADER
};
struct RenderPathEnum
{
static RenderPath FromString(const CStr8& name);
static CStr8 ToString(RenderPath);
};
class CRenderingOptions
{
// The renderer needs access to our private variables directly because capabilities have not yet been extracted
// and thus sometimes it needs to change the rendering options without the side-effects.
friend class CRenderer;
public:
CRenderingOptions();
~CRenderingOptions();
void ReadConfigAndSetupHooks();
void ClearHooks();
#define OPTION_DEFAULT_SETTER(NAME, TYPE) \
public: void Set##NAME(TYPE value) { m_##NAME = value; }\
#define OPTION_CUSTOM_SETTER(NAME, TYPE) \
public: void Set##NAME(TYPE value);\
#define OPTION_GETTER(NAME, TYPE)\
public: TYPE Get##NAME() const { return m_##NAME; }\
#define OPTION_DEF(NAME, TYPE)\
private: TYPE m_##NAME;
#define OPTION(NAME, TYPE)\
OPTION_DEFAULT_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
#define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)\
OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
OPTION_WITH_SIDE_EFFECT(Shadows, bool);
OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
OPTION_WITH_SIDE_EFFECT(PreferGLSL, bool);
OPTION_WITH_SIDE_EFFECT(Fog, bool);
OPTION_WITH_SIDE_EFFECT(RenderPath, RenderPath);
OPTION(WaterEffects, bool);
OPTION(WaterFancyEffects, bool);
OPTION(WaterRealDepth, bool);
OPTION(WaterRefraction, bool);
OPTION(WaterReflection, bool);
OPTION(ShadowAlphaFix, bool);
OPTION(ARBProgramShadow, bool);
OPTION(Particles, bool);
OPTION(ForceAlphaTest, bool);
OPTION(GPUSkinning, bool);
OPTION(Silhouettes, bool);
OPTION(SmoothLOS, bool);
OPTION(PostProc, bool);
OPTION(DisplayFrustum, bool);
OPTION(DisplayShadowsFrustum, bool);
OPTION(RenderActors, bool);
#undef OPTION_DEFAULT_SETTER
#undef OPTION_CUSTOM_SETTER
#undef OPTION_GETTER
#undef OPTION_DEF
#undef OPTION
#undef OPTION_WITH_SIDE_EFFECT
private:
class ConfigHooks;
std::unique_ptr m_ConfigHooks; // Hide this via PImpl to avoid including ConfigDB.h here.
};
extern CRenderingOptions g_RenderingOptions;
#endif // INCLUDED_RENDERINGOPTIONS
Index: ps/trunk/source/renderer/TerrainRenderer.h
===================================================================
--- ps/trunk/source/renderer/TerrainRenderer.h (revision 25902)
+++ ps/trunk/source/renderer/TerrainRenderer.h (revision 25903)
@@ -1,167 +1,166 @@
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
/*
* Terrain rendering (everything related to patches and water) is
* encapsulated in TerrainRenderer
*/
#ifndef INCLUDED_TERRAINRENDERER
#define INCLUDED_TERRAINRENDERER
#include "graphics/Color.h"
#include "maths/BoundingBoxAligned.h"
class CCamera;
class CMatrix3D;
class CModelDecal;
class CPatch;
class CShaderDefines;
class CSimulation2;
class ShadowMap;
-class WaterManager;
struct TerrainRendererInternals;
/**
* Class TerrainRenderer: Render everything related to the terrain,
* especially patches and water.
*/
class TerrainRenderer
{
friend class CPatchRData;
friend class CDecalRData;
public:
TerrainRenderer();
~TerrainRenderer();
/**
* Set the simulation context for this frame.
* Call at start of frame, before any other Submits.
*/
void SetSimulation(CSimulation2* simulation);
/**
* Submit: Add a patch for rendering in this frame.
*
* preconditions : PrepareForRendering must not have been called
* for this frame yet.
* The patch must not have been submitted in this frame yet (i.e. you
* can only submit a frame once).
*
* @param patch the patch
*/
void Submit(int cullGroup, CPatch* patch);
/**
* Submit: Add a terrain decal for rendering in this frame.
*/
void Submit(int cullGroup, CModelDecal* decal);
/**
* PrepareForRendering: Prepare internal data structures like vertex
* buffers for rendering.
*
* All patches must have been submitted before the call to
* PrepareForRendering.
* PrepareForRendering must be called before any rendering calls.
*/
void PrepareForRendering();
/**
* EndFrame: Remove all patches from the list of submitted patches.
*/
void EndFrame();
/**
* Render textured terrain (including blends between
* different terrain types).
*
* preconditions : PrepareForRendering must have been called this
* frame before calling RenderTerrain.
*
* @param shadow A prepared shadow map, in case rendering with shadows is enabled.
*/
void RenderTerrainShader(const CShaderDefines& context, int cullGroup, ShadowMap* shadow);
/**
* RenderPatches: Render all patches un-textured as polygons.
*
* preconditions : PrepareForRendering must have been called this
* frame before calling RenderPatches.
*
* @param filtered If true then only render objects that passed CullPatches.
* @param color Fill color of the patches.
*/
void RenderPatches(int cullGroup, const CColor& color = CColor(0.0f, 0.0f, 0.0f, 1.0f));
/**
* RenderOutlines: Render the outline of patches as lines.
*
* preconditions : PrepareForRendering must have been called this
* frame before calling RenderOutlines.
*
* @param filtered If true then only render objects that passed CullPatches.
*/
void RenderOutlines(int cullGroup);
/**
* RenderWater: Render water for all patches that have been submitted
* this frame.
*
* preconditions : PrepareForRendering must have been called this
* frame before calling RenderWater.
*/
void RenderWater(const CShaderDefines& context, int cullGroup, ShadowMap* shadow);
/**
* Calculate a scissor rectangle for the visible water patches.
*/
CBoundingBoxAligned ScissorWater(int cullGroup, const CCamera& camera);
/**
* Render priority text for all submitted patches, for debugging.
*/
void RenderPriorities(int cullGroup);
/**
* Render texture unit 0 over the terrain mesh, with UV coords calculated
* by the given texture matrix.
* Intended for use by TerrainTextureOverlay.
*/
void RenderTerrainOverlayTexture(int cullGroup, CMatrix3D& textureMatrix, GLuint texture);
private:
TerrainRendererInternals* m;
/**
* RenderFancyWater: internal rendering method for fancy water.
* Returns false if unable to render with fancy water.
*/
bool RenderFancyWater(const CShaderDefines& context, int cullGroup, ShadowMap* shadow);
/**
* RenderSimpleWater: internal rendering method for water
*/
void RenderSimpleWater(int cullGroup);
static void PrepareShader(const CShaderProgramPtr& shader, ShadowMap* shadow);
};
#endif // INCLUDED_TERRAINRENDERER
Index: ps/trunk/source/simulation2/components/ICmpGuiInterface.h
===================================================================
--- ps/trunk/source/simulation2/components/ICmpGuiInterface.h (revision 25902)
+++ ps/trunk/source/simulation2/components/ICmpGuiInterface.h (revision 25903)
@@ -1,37 +1,35 @@
-/* Copyright (C) 2010 Wildfire Games.
+/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_ICMPGUIINTERFACE
#define INCLUDED_ICMPGUIINTERFACE
#include "simulation2/system/Interface.h"
-struct CColor;
-
class ICmpGuiInterface : public IComponent
{
public:
/**
* Generic call function, for use by GUI scripts to talk to the GuiInterface script.
*/
virtual void ScriptCall(int player, const std::wstring& cmd, JS::HandleValue data, JS::MutableHandleValue ret) = 0;
// TODO: some of the earlier functions should just use ScriptCall.
DECLARE_INTERFACE_TYPE(GuiInterface)
};
#endif // INCLUDED_ICMPGUIINTERFACE
Index: ps/trunk/source/soundmanager/scripting/SoundGroup.h
===================================================================
--- ps/trunk/source/soundmanager/scripting/SoundGroup.h (revision 25902)
+++ ps/trunk/source/soundmanager/scripting/SoundGroup.h (revision 25903)
@@ -1,117 +1,116 @@
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_SOUNDGROUP_H
#define INCLUDED_SOUNDGROUP_H
#include "lib/config2.h"
#include "lib/file/vfs/vfs_path.h"
#include "lib/types.h"
#include "simulation2/system/Entity.h"
#include "soundmanager/data/SoundData.h"
#include
class CVector3D;
-class ISoundItem;
enum eSndGrpFlags
{
eRandOrder = 0x01,
eRandGain = 0x02,
eRandPitch = 0x04,
eLoop = 0x08,
eOmnipresent = 0x10,
eDistanceless = 0x20,
eOwnerOnly = 0x40
};
// Loads up a group of sound files with shared properties,
// and provides a simple interface for playing them.
class CSoundGroup
{
NONCOPYABLE(CSoundGroup);
public:
CSoundGroup(const VfsPath& pathnameXML);
CSoundGroup();
~CSoundGroup();
// Play next sound in group
// @param position world position of the entity generating the sound
// (ignored if the eOmnipresent flag is set)
void PlayNext(const CVector3D& position, entity_id_t source);
float RadiansOffCenter(const CVector3D& position, bool& onScreen, float& itemRollOff);
// Load a group
bool LoadSoundGroup(const VfsPath& pathnameXML);
void Reload();
// Release all remaining loaded handles
void ReleaseGroup();
// Update SoundGroup, remove dead sounds from intensity count
void Update(float TimeSinceLastFrame);
// Set a flag using a value from eSndGrpFlags
inline void SetFlag(int flag) { m_Flags = (unsigned char)(m_Flags | flag); }
// Test flag, returns true if flag is set.
inline bool TestFlag(int flag) { return (m_Flags & flag) != 0; }
private:
void SetGain(float gain);
void UploadPropertiesAndPlay(size_t theIndex, const CVector3D& position, entity_id_t source);
void SetDefaultValues();
#if CONFIG2_AUDIO
// We store the handles so we can load now and play later
std::vector m_SoundGroups;
#endif
u32 m_Seed;
// We need the filenames so we can reload when necessary.
std::vector m_Filenames;
// The file path for the list of sound file resources
VfsPath m_Filepath;
size_t m_CurrentSoundIndex;
float m_ConeInnerAngle;
float m_ConeOuterAngle;
float m_ConeOuterGain;
// Time elapsed since soundgroup was created
float m_CurTime;
float m_Decay;
float m_Gain;
float m_GainUpper;
float m_GainLower;
// Distance attenuation settings
float m_MinDist;
float m_MaxDist;
// How much stereo separation to apply to sounds based on L-R position relative to the camera.
float m_MaxStereoAngle;
// The allowable intensity before a sound switch
float m_IntensityThreshold;
float m_Pitch;
float m_PitchLower;
float m_PitchUpper;
float m_Priority;
// Up to eight individual parameters, use with eSndGrpFlags.
u8 m_Flags;
};
#endif //#ifndef INCLUDED_SOUNDGROUP_H
Index: ps/trunk/source/collada/CommonConvert.h
===================================================================
--- ps/trunk/source/collada/CommonConvert.h (revision 25902)
+++ ps/trunk/source/collada/CommonConvert.h (revision 25903)
@@ -1,181 +1,180 @@
-/* Copyright (C) 2015 Wildfire Games.
+/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_COMMONCONVERT
#define INCLUDED_COMMONCONVERT
#include
#include
#include
#include
class FCDEntityInstance;
class FCDSceneNode;
class FCDSkinController;
class FMMatrix44;
-class FUStatus;
class Skeleton;
class ColladaException : public std::exception
{
public:
ColladaException(const std::string& msg) : msg(msg) { }
~ColladaException() throw() { }
virtual const char* what() const throw() { return msg.c_str(); }
private:
std::string msg;
};
struct OutputCB
{
virtual ~OutputCB() { }
virtual void operator() (const char* data, unsigned int length)=0;
};
/**
* Standard error handler - logs FCollada messages using Log(), and also
* maintains a list of XML parser errors.
*/
class FColladaErrorHandler
{
public:
FColladaErrorHandler(std::string& xmlErrors);
~FColladaErrorHandler();
private:
void OnError(FUError::Level errorLevel, uint32 errorCode, uint32 lineNumber);
std::string& xmlErrors;
void operator=(FColladaErrorHandler);
};
/**
* Standard document loader. Based on FCDocument::LoadFromText, but allows
* access to \ nodes at the document level (i.e. directly in \).
*/
class FColladaDocument
{
public:
/**
* Loads the document from the given XML string. Should be the first function
* called on this object, and should only be called once.
* @throws ColladaException if unable to load.
*/
void LoadFromText(const char* text);
/** Returns the FCDocument that was loaded. */
FCDocument* GetDocument() const { return document.get(); }
/** Returns the \ data from the \ element. */
FCDExtra* GetExtra() const { return extra.get(); }
private:
void ReadExtras(xmlNode* colladaNode);
std::unique_ptr document;
std::unique_ptr extra;
};
/**
* Wrapper for code shared between the PMD and PSA converters. Loads the document
* and provides access to the relevant objects and values.
*/
class CommonConvert
{
public:
CommonConvert(const char* text, std::string& xmlErrors);
~CommonConvert();
const FColladaDocument& GetDocument() const { return m_Doc; }
FCDSceneNode& GetRoot() { return *m_Doc.GetDocument()->GetVisualSceneRoot(); }
FCDEntityInstance& GetInstance() { return *m_Instance; }
const FMMatrix44& GetEntityTransform() const { return m_EntityTransform; }
bool IsYUp() const { return m_YUp; }
bool IsXSI() const { return m_IsXSI; }
private:
FColladaErrorHandler m_Err;
FColladaDocument m_Doc;
FCDEntityInstance* m_Instance;
FMMatrix44 m_EntityTransform;
bool m_YUp;
bool m_IsXSI;
};
/** Throws a ColladaException unless the value is true. */
#define REQUIRE(value, message) require_(__LINE__, value, "Assertion not satisfied", "failed requirement \"" message "\"")
/** Throws a ColladaException unless the status is successful. */
#define REQUIRE_SUCCESS(status) require_(__LINE__, status, "FCollada error", "Line " STRINGIFY(__LINE__))
#define STRINGIFY(x) #x
void require_(int line, bool value, const char* type, const char* message);
/** Outputs a structure, using sizeof to get the size. */
template void write(OutputCB& output, const T& data)
{
output((char*)&data, sizeof(T));
}
/**
* Tries to find a single suitable entity instance in the scene. Fails if there
* are none, or if there are too many and it's not clear which one should
* be converted.
*
* @param node root scene node to search under
* @param instance output - the found entity instance (if any)
* @param transform - the world-space transform of the found entity
*
* @return true if one was found
*/
bool FindSingleInstance(FCDSceneNode* node, FCDEntityInstance*& instance, FMMatrix44& transform);
/**
* Like FCDSkinController::ReduceInfluences but works correctly.
* Additionally, multiple influences for the same joint-vertex pair are
* collapsed into a single influence.
*/
void SkinReduceInfluences(FCDSkinController* skin, size_t maxInfluenceCount, float minimumWeight);
/**
* Fixes some occasional problems with the skeleton root definitions in a
* controller. (In particular, it's needed for models exported from XSI.)
* Should be called before extracting any joint information from the controller.
*/
void FixSkeletonRoots(FCDControllerInstance& controllerInstance);
/**
* Finds the skeleton definition which best matches the given controller.
* @throws ColladaException if none is found.
*/
const Skeleton& FindSkeleton(const FCDControllerInstance& controllerInstance);
/** Bone pose data */
struct BoneTransform
{
float translation[3];
float orientation[4];
};
/**
* Performs the standard transformations on bones, applying a scale matrix and
* moving them into the game's coordinate space.
*/
void TransformBones(std::vector& bones, const FMMatrix44& scaleTransform, bool yUp);
extern FMMatrix44 FMMatrix44_Identity;
#endif // INCLUDED_COMMONCONVERT
Index: ps/trunk/source/graphics/ColladaManager.h
===================================================================
--- ps/trunk/source/graphics/ColladaManager.h (revision 25902)
+++ ps/trunk/source/graphics/ColladaManager.h (revision 25903)
@@ -1,68 +1,66 @@
-/* Copyright (C) 2013 Wildfire Games.
+/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_COLLADAMANAGER
#define INCLUDED_COLLADAMANAGER
#include "lib/file/vfs/vfs.h"
-class CStr8;
class CColladaManagerImpl;
-class MD5;
class CColladaManager
{
NONCOPYABLE(CColladaManager);
public:
enum FileType { PMD, PSA };
CColladaManager(const PIVFS& vfs);
~CColladaManager();
/**
* Returns the VFS path to a PMD/PSA file for the given source file.
* Performs a (cached) conversion from COLLADA if necessary.
*
* @param pathnameNoExtension path and name, minus extension, of file to load.
* One of either "sourceName.pmd" or "sourceName.dae" should exist.
* @param type FileType, .pmd or .psa
*
* @return full VFS path (including extension) of file to load; or empty
* string if there was a problem and it could not be loaded. Doesn't knowingly
* return an invalid path.
*/
VfsPath GetLoadablePath(const VfsPath& pathnameNoExtension, FileType type);
/**
* Converts DAE to archive cached .pmd/psa and outputs the resulting path
* (used by archive builder)
*
* @param[in] sourcePath path of the .dae to load
* @param[in] type FileType, .pmd or .psa
* @param[out] archiveCachePath output path of the cached file
*
* @return true if COLLADA converter completed successfully; or false if it failed
*/
bool GenerateCachedFile(const VfsPath& sourcePath, FileType type, VfsPath& archiveCachePath);
private:
CColladaManagerImpl* m;
PIVFS m_VFS;
};
#endif // INCLUDED_COLLADAMANAGER
Index: ps/trunk/source/graphics/Font.h
===================================================================
--- ps/trunk/source/graphics/Font.h (revision 25902)
+++ ps/trunk/source/graphics/Font.h (revision 25903)
@@ -1,101 +1,99 @@
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_FONT
#define INCLUDED_FONT
#include "graphics/Texture.h"
#include "lib/res/handle.h"
-struct UnifontGlyphData;
-
/**
* Storage for a bitmap font. Loaded by CFontManager.
*/
class CFont
{
friend class CFontManager;
CFont() {}
public:
struct GlyphData
{
float u0, v0, u1, v1;
i16 x0, y0, x1, y1;
i16 xadvance;
u8 defined;
};
/**
* Relatively efficient lookup of GlyphData from 16-bit Unicode codepoint.
* This is stored as a sparse 2D array, exploiting the knowledge that a font
* typically only supports a small number of 256-codepoint blocks, so most
* elements of m_Data will be NULL.
*/
class GlyphMap
{
NONCOPYABLE(GlyphMap);
public:
GlyphMap();
~GlyphMap();
void set(u16 i, const GlyphData& val);
const GlyphData* get(u16 i) const
{
if (!m_Data[i >> 8])
return NULL;
if (!m_Data[i >> 8][i & 0xff].defined)
return NULL;
return &m_Data[i >> 8][i & 0xff];
}
private:
GlyphData* m_Data[256];
};
bool HasRGB() const { return m_HasRGB; }
int GetLineSpacing() const { return m_LineSpacing; }
int GetHeight() const { return m_Height; }
int GetCharacterWidth(wchar_t c) const;
void CalculateStringSize(const wchar_t* string, int& w, int& h) const;
void GetGlyphBounds(float& x0, float& y0, float& x1, float& y1) const
{
x0 = m_BoundsX0;
y0 = m_BoundsY0;
x1 = m_BoundsX1;
y1 = m_BoundsY1;
}
const GlyphMap& GetGlyphs() const { return m_Glyphs; }
CTexturePtr GetTexture() const { return m_Texture; }
private:
CTexturePtr m_Texture;
bool m_HasRGB; // true if RGBA, false if ALPHA
GlyphMap m_Glyphs;
int m_LineSpacing;
int m_Height; // height of a capital letter, roughly
// Bounding box of all glyphs
float m_BoundsX0;
float m_BoundsY0;
float m_BoundsX1;
float m_BoundsY1;
};
#endif // INCLUDED_FONT
Index: ps/trunk/source/graphics/MapReader.h
===================================================================
--- ps/trunk/source/graphics/MapReader.h (revision 25902)
+++ ps/trunk/source/graphics/MapReader.h (revision 25903)
@@ -1,183 +1,182 @@
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_MAPREADER
#define INCLUDED_MAPREADER
#include "MapIO.h"
#include "graphics/LightEnv.h"
#include "lib/res/handle.h"
#include "ps/CStr.h"
#include "ps/FileIo.h"
#include "scriptinterface/ScriptTypes.h"
#include "simulation2/system/Entity.h"
-class CObjectEntry;
class CTerrain;
class WaterManager;
class SkyManager;
class CLightEnv;
class CCinemaManager;
class CPostprocManager;
class CTriggerManager;
class CSimulation2;
class CSimContext;
class CTerrainTextureEntry;
class CGameView;
class CXMLReader;
class CMapGenerator;
class ScriptContext;
class ScriptInterface;
class CMapReader : public CMapIO
{
friend class CXMLReader;
public:
// constructor
CMapReader();
~CMapReader();
// LoadMap: try to load the map from given file; reinitialise the scene to new data if successful
void LoadMap(const VfsPath& pathname, const ScriptContext& cx, JS::HandleValue settings, CTerrain*, WaterManager*, SkyManager*, CLightEnv*, CGameView*,
CCinemaManager*, CTriggerManager*, CPostprocManager* pPostproc, CSimulation2*, const CSimContext*,
int playerID, bool skipEntities);
void LoadRandomMap(const CStrW& scriptFile, const ScriptContext& cx, JS::HandleValue settings, CTerrain*, WaterManager*, SkyManager*, CLightEnv*, CGameView*, CCinemaManager*, CTriggerManager*, CPostprocManager* pPostproc_, CSimulation2*, int playerID);
private:
// Load script settings for use by scripts
int LoadScriptSettings();
// load player settings only
int LoadPlayerSettings();
// load map settings only
int LoadMapSettings();
// UnpackTerrain: unpack the terrain from the input stream
int UnpackTerrain();
// UnpackCinema: unpack the cinematic tracks from the input stream
int UnpackCinema();
// UnpackMap: unpack the given data from the raw data stream into local variables
int UnpackMap();
// ApplyData: take all the input data, and rebuild the scene from it
int ApplyData();
int ApplyTerrainData();
// read some misc data from the XML file
int ReadXML();
// read entity data from the XML file
int ReadXMLEntities();
// Copy random map settings over to sim
int LoadRMSettings();
// Generate random map
int GenerateMap();
// Parse script data into terrain
int ParseTerrain();
// Parse script data into entities
int ParseEntities();
// Parse script data into environment
int ParseEnvironment();
// Parse script data into camera
int ParseCamera();
// size of map
ssize_t m_PatchesPerSide;
// heightmap for map
std::vector m_Heightmap;
// list of terrain textures used by map
std::vector m_TerrainTextures;
// tile descriptions for each tile
std::vector m_Tiles;
// lightenv stored in file
CLightEnv m_LightEnv;
// startup script
CStrW m_Script;
// random map data
CStrW m_ScriptFile;
JS::PersistentRootedValue m_ScriptSettings;
JS::PersistentRootedValue m_MapData;
CMapGenerator* m_MapGen;
CFileUnpacker unpacker;
CTerrain* pTerrain;
WaterManager* pWaterMan;
SkyManager* pSkyMan;
CPostprocManager* pPostproc;
CLightEnv* pLightEnv;
CGameView* pGameView;
CCinemaManager* pCinema;
CTriggerManager* pTrigMan;
CSimulation2* pSimulation2;
const CSimContext* pSimContext;
int m_PlayerID;
bool m_SkipEntities;
VfsPath filename_xml;
bool only_xml;
u32 file_format_version;
entity_id_t m_StartingCameraTarget;
CVector3D m_StartingCamera;
// UnpackTerrain generator state
size_t cur_terrain_tex;
size_t num_terrain_tex;
CXMLReader* xml_reader;
};
/**
* A restricted map reader that returns various summary information
* for use by scripts (particularly the GUI).
*/
class CMapSummaryReader
{
public:
/**
* Try to load a map file.
* @param pathname Path to .pmp or .xml file
*/
PSRETURN LoadMap(const VfsPath& pathname);
/**
* Returns a value of the form:
* @code
* {
* "settings": { ... contents of the map's ... }
* }
* @endcode
*/
void GetMapSettings(const ScriptInterface& scriptInterface, JS::MutableHandleValue);
private:
CStr m_ScriptSettings;
};
#endif
Index: ps/trunk/source/graphics/MapWriter.h
===================================================================
--- ps/trunk/source/graphics/MapWriter.h (revision 25902)
+++ ps/trunk/source/graphics/MapWriter.h (revision 25903)
@@ -1,71 +1,68 @@
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_MAPWRITER
#define INCLUDED_MAPWRITER
#include "MapIO.h"
#include "ps/CStr.h"
#include "ps/FileIo.h"
#include
class CLightEnv;
class CTerrain;
class CCamera;
class CCinemaManager;
class CPostprocManager;
-class CTriggerManager;
class WaterManager;
class SkyManager;
class CSimulation2;
struct MapTrigger;
-struct MapTriggerGroup;
-class XMLWriter_File;
class CMapWriter : public CMapIO
{
public:
// constructor
CMapWriter();
// SaveMap: try to save the current map to the given file
void SaveMap(const VfsPath& pathname, CTerrain* pTerr,
WaterManager* pWaterMan, SkyManager* pSkyMan,
CLightEnv* pLightEnv, CCamera* pCamera,
CCinemaManager* pCinema, CPostprocManager* pPostproc,
CSimulation2* pSimulation2);
private:
// PackMap: pack the current world into a raw data stream
void PackMap(CFilePacker& packer, CTerrain* pTerrain);
// PackTerrain: pack the terrain onto the end of the data stream
void PackTerrain(CFilePacker& packer, CTerrain* pTerrain);
// EnumTerrainTextures: build lists of textures used by map, and indices into this list
// for each tile on the terrain
void EnumTerrainTextures(CTerrain* pTerrain, std::vector& textures,
std::vector& tileIndices);
// WriteXML: output some other data (entities, etc) in XML format
void WriteXML(const VfsPath& pathname, WaterManager* pWaterMan,
SkyManager* pSkyMan, CLightEnv* pLightEnv, CCamera* pCamera,
CPostprocManager* pPostproc,
CSimulation2* pSimulation2);
};
#endif
Index: ps/trunk/source/graphics/ObjectBase.h
===================================================================
--- ps/trunk/source/graphics/ObjectBase.h (revision 25902)
+++ ps/trunk/source/graphics/ObjectBase.h (revision 25903)
@@ -1,274 +1,272 @@
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
#ifndef INCLUDED_OBJECTBASE
#define INCLUDED_OBJECTBASE
#include "lib/file/vfs/vfs_path.h"
#include "ps/CStr.h"
#include "ps/CStrIntern.h"
class CActorDef;
-class CModel;
class CObjectEntry;
class CObjectManager;
-class CSkeletonAnim;
class CXeromyces;
class XMBElement;
#include
#include