Decouple includes; Remove some unused variable; Fix an equation in Space.cpp
parent
539884332b
commit
e6403fc1ad
|
@ -252,7 +252,6 @@ namespace Background {
|
|||
const SystemPath current = Pi::game->GetSpace()->GetStarSystem()->GetPath();
|
||||
|
||||
const double size = 1.0;
|
||||
const Uint8 colScale = size * 255;
|
||||
const Sint32 visibleRadius = 100; // lyrs
|
||||
const Sint32 visibleRadiusSqr = (visibleRadius * visibleRadius);
|
||||
const Sint32 sectorMin = -(visibleRadius / Sector::SIZE); // lyrs_radius / sector_size_in_lyrs
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
#ifndef _BACKGROUND_H
|
||||
#define _BACKGROUND_H
|
||||
|
||||
#include "Random.h"
|
||||
#include "graphics/Drawables.h"
|
||||
|
||||
class Random;
|
||||
|
||||
namespace Graphics {
|
||||
class Renderer;
|
||||
class Material;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "GeoSphere.h"
|
||||
|
||||
#include "graphics/Renderer.h"
|
||||
#include "graphics/Drawables.h"
|
||||
|
||||
BaseSphere::BaseSphere(const SystemBody *body) :
|
||||
m_sbody(body),
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
#include "Camera.h"
|
||||
#include "vector3.h"
|
||||
#include "galaxy/AtmosphereParameters.h"
|
||||
#include "graphics/Drawables.h"
|
||||
#include "graphics/Material.h"
|
||||
#include "terrain/Terrain.h"
|
||||
|
||||
namespace Graphics {
|
||||
class Renderer;
|
||||
class RenderState;
|
||||
class Material;
|
||||
namespace Drawables {
|
||||
class Sphere3D;
|
||||
}
|
||||
} // namespace Graphics
|
||||
|
||||
class BaseSphere {
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#include "Sfx.h"
|
||||
#include "Ship.h"
|
||||
#include "Space.h"
|
||||
#include "collider/collider.h"
|
||||
#include "galaxy/StarSystem.h"
|
||||
#include "collider/CollisionContact.h"
|
||||
#include "collider/CollisionSpace.h"
|
||||
#include "graphics/Graphics.h"
|
||||
#include "graphics/Material.h"
|
||||
#include "graphics/Renderer.h"
|
||||
|
|
11
src/Beam.h
11
src/Beam.h
|
@ -7,14 +7,19 @@
|
|||
#define _BEAM_H
|
||||
|
||||
#include "Body.h"
|
||||
#include "graphics/Material.h"
|
||||
#include "Color.h"
|
||||
#include "Object.h"
|
||||
#include "matrix4x4.h"
|
||||
#include "vector3.h"
|
||||
|
||||
class Frame;
|
||||
class Camera;
|
||||
class Space;
|
||||
|
||||
namespace Graphics {
|
||||
class Material;
|
||||
class Renderer;
|
||||
class VertexArray;
|
||||
class RenderState;
|
||||
class VertexArray;
|
||||
} // namespace Graphics
|
||||
|
||||
struct ProjectileData;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "Frame.h"
|
||||
#include "GameSaveError.h"
|
||||
#include "HyperspaceCloud.h"
|
||||
#include "JsonUtils.h"
|
||||
#include "LuaEvent.h"
|
||||
#include "Missile.h"
|
||||
#include "Planet.h"
|
||||
|
@ -17,7 +16,6 @@
|
|||
#include "Space.h"
|
||||
#include "SpaceStation.h"
|
||||
#include "Star.h"
|
||||
#include "libs.h"
|
||||
|
||||
Body::Body() :
|
||||
PropertiedObject(Lua::manager),
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Object.h"
|
||||
#include "PropertiedObject.h"
|
||||
#include "matrix4x4.h"
|
||||
#include "matrix3x3.h"
|
||||
#include "vector3.h"
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "Camera.h"
|
||||
|
||||
#include "Body.h"
|
||||
#include "Frame.h"
|
||||
#include "Game.h"
|
||||
#include "Pi.h"
|
||||
|
@ -74,6 +75,24 @@ void CameraContext::ApplyDrawTransforms(Graphics::Renderer *r)
|
|||
r->SetTransform(matrix4x4f::Identity());
|
||||
}
|
||||
|
||||
bool Camera::BodyAttrs::sort_BodyAttrs(const BodyAttrs &a, const BodyAttrs &b)
|
||||
{
|
||||
// both drawing last; distance order
|
||||
if (a.bodyFlags & Body::FLAG_DRAW_LAST && b.bodyFlags & Body::FLAG_DRAW_LAST)
|
||||
return a.camDist > b.camDist;
|
||||
|
||||
// a drawing last; draw b first
|
||||
if (a.bodyFlags & Body::FLAG_DRAW_LAST)
|
||||
return false;
|
||||
|
||||
// b drawing last; draw a first
|
||||
if (b.bodyFlags & Body::FLAG_DRAW_LAST)
|
||||
return true;
|
||||
|
||||
// both in normal draw; distance order
|
||||
return a.camDist > b.camDist;
|
||||
}
|
||||
|
||||
Camera::Camera(RefCountedPtr<CameraContext> context, Graphics::Renderer *renderer) :
|
||||
m_context(context),
|
||||
m_renderer(renderer)
|
||||
|
|
26
src/Camera.h
26
src/Camera.h
|
@ -4,12 +4,13 @@
|
|||
#ifndef _CAMERA_H
|
||||
#define _CAMERA_H
|
||||
|
||||
#include "Body.h"
|
||||
#include "Color.h"
|
||||
#include "graphics/Frustum.h"
|
||||
#include "graphics/Light.h"
|
||||
#include "matrix4x4.h"
|
||||
#include "vector3.h"
|
||||
|
||||
class Body;
|
||||
class Frame;
|
||||
class ShipCockpit;
|
||||
|
||||
|
@ -139,23 +140,12 @@ private:
|
|||
Color billboardColor;
|
||||
|
||||
// for sorting. "should a be drawn before b?"
|
||||
friend bool operator<(const BodyAttrs &a, const BodyAttrs &b)
|
||||
{
|
||||
// both drawing last; distance order
|
||||
if (a.bodyFlags & Body::FLAG_DRAW_LAST && b.bodyFlags & Body::FLAG_DRAW_LAST)
|
||||
return a.camDist > b.camDist;
|
||||
|
||||
// a drawing last; draw b first
|
||||
if (a.bodyFlags & Body::FLAG_DRAW_LAST)
|
||||
return false;
|
||||
|
||||
// b drawing last; draw a first
|
||||
if (b.bodyFlags & Body::FLAG_DRAW_LAST)
|
||||
return true;
|
||||
|
||||
// both in normal draw; distance order
|
||||
return a.camDist > b.camDist;
|
||||
}
|
||||
// NOTE: Add below function (thus an indirection) in order
|
||||
// to decouple Camera from Body.h
|
||||
static bool sort_BodyAttrs(const BodyAttrs &a, const BodyAttrs &b);
|
||||
friend bool operator<(const BodyAttrs &a, const BodyAttrs &b) {
|
||||
return sort_BodyAttrs(a, b);
|
||||
};
|
||||
};
|
||||
|
||||
std::list<BodyAttrs> m_sortedBodies;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "CityOnPlanet.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "Frame.h"
|
||||
#include "Game.h"
|
||||
|
@ -10,6 +11,7 @@
|
|||
#include "Planet.h"
|
||||
#include "SpaceStation.h"
|
||||
#include "collider/Geom.h"
|
||||
#include "graphics/Frustum.h"
|
||||
#include "scenegraph/Animation.h"
|
||||
#include "scenegraph/ModelSkin.h"
|
||||
#include "scenegraph/SceneGraph.h"
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "CollMesh.h"
|
||||
|
||||
#include "scenegraph/Serializer.h"
|
||||
#include "collider/GeomTree.h"
|
||||
|
||||
//This simply stores the collision GeomTrees
|
||||
//and AABB.
|
||||
|
@ -41,3 +43,30 @@ void CollMesh::Load(Serializer::Reader &rd)
|
|||
|
||||
m_totalTris = rd.Int32();
|
||||
}
|
||||
|
||||
CollMesh::~CollMesh()
|
||||
{
|
||||
for (auto it = m_dynGeomTrees.begin(); it != m_dynGeomTrees.end(); ++it)
|
||||
delete *it;
|
||||
delete m_geomTree;
|
||||
}
|
||||
|
||||
const std::vector<vector3f> &CollMesh::GetGeomTreeVertices() const
|
||||
{
|
||||
return m_geomTree->GetVertices();
|
||||
}
|
||||
|
||||
const Uint32 *CollMesh::GetGeomTreeIndices() const
|
||||
{
|
||||
return m_geomTree->GetIndices();
|
||||
}
|
||||
|
||||
const unsigned int *CollMesh::GetGeomTreeTriFlags() const
|
||||
{
|
||||
return m_geomTree->GetTriFlags();
|
||||
}
|
||||
|
||||
unsigned int CollMesh::GetGeomTreeNumTris() const
|
||||
{
|
||||
return m_geomTree->GetNumTris();
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
#ifndef _COLLMESH_H
|
||||
#define _COLLMESH_H
|
||||
|
||||
#include "Aabb.h"
|
||||
#include "RefCounted.h"
|
||||
#include "collider/GeomTree.h"
|
||||
|
||||
class GeomTree;
|
||||
|
||||
namespace Serializer {
|
||||
class Writer;
|
||||
|
@ -20,12 +22,8 @@ public:
|
|||
m_geomTree(0),
|
||||
m_totalTris(0)
|
||||
{}
|
||||
virtual ~CollMesh()
|
||||
{
|
||||
for (auto it = m_dynGeomTrees.begin(); it != m_dynGeomTrees.end(); ++it)
|
||||
delete *it;
|
||||
delete m_geomTree;
|
||||
}
|
||||
virtual ~CollMesh();
|
||||
|
||||
inline Aabb &GetAabb() { return m_aabb; }
|
||||
|
||||
inline double GetRadius() const { return m_aabb.GetRadius(); }
|
||||
|
@ -35,7 +33,13 @@ public:
|
|||
m_aabb.radius = std::max(v, 0.1);
|
||||
}
|
||||
|
||||
const std::vector<vector3f> &GetGeomTreeVertices() const;
|
||||
const Uint32 *GetGeomTreeIndices() const;
|
||||
const unsigned int *GetGeomTreeTriFlags() const;
|
||||
unsigned int GetGeomTreeNumTris() const;
|
||||
|
||||
inline GeomTree *GetGeomTree() const { return m_geomTree; }
|
||||
|
||||
inline void SetGeomTree(GeomTree *t)
|
||||
{
|
||||
assert(t);
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "DeathView.h"
|
||||
|
||||
#include "Camera.h"
|
||||
#include "Game.h"
|
||||
#include "GameConfig.h"
|
||||
#include "Pi.h"
|
||||
#include "Player.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "Json.h"
|
||||
#include "Planet.h"
|
||||
#include "Space.h"
|
||||
#include "collider/CollisionContact.h"
|
||||
#include "ship/Propulsion.h"
|
||||
|
||||
static const float KINETIC_ENERGY_MULT = 0.00001f;
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "Frame.h"
|
||||
#include "Body.h"
|
||||
|
||||
#include "GameSaveError.h"
|
||||
#include "JsonUtils.h"
|
||||
#include "Sfx.h"
|
||||
#include "Space.h"
|
||||
#include "collider/collider.h"
|
||||
#include "collider/CollisionSpace.h"
|
||||
#include "utils.h"
|
||||
|
||||
Frame::Frame()
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "LuaEvent.h"
|
||||
#include "LuaSerializer.h"
|
||||
#include "MathUtil.h"
|
||||
#include "Object.h"
|
||||
#if WITH_OBJECTVIEWER
|
||||
#include "ObjectViewerView.h"
|
||||
#endif
|
||||
|
@ -30,7 +31,6 @@
|
|||
#include "UIView.h"
|
||||
#include "WorldView.h"
|
||||
#include "galaxy/GalaxyGenerator.h"
|
||||
#include "graphics/Renderer.h"
|
||||
#include "ship/PlayerShipController.h"
|
||||
|
||||
static const int s_saveVersion = 85;
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#include "JsonFwd.h"
|
||||
#include "galaxy/Galaxy.h"
|
||||
#include "galaxy/SystemPath.h"
|
||||
#include "gameconsts.h"
|
||||
#include <string>
|
||||
|
||||
class SystemPath;
|
||||
class GameLog;
|
||||
class HyperspaceCloud;
|
||||
class Player;
|
||||
|
@ -34,8 +34,6 @@ class SystemInfoView;
|
|||
class SystemView;
|
||||
class WorldView;
|
||||
class DeathView;
|
||||
class UIView;
|
||||
class UIView;
|
||||
class ShipCpanel;
|
||||
class ObjectViewerView;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "Game.h"
|
||||
#include "GameConfig.h"
|
||||
#include "Pi.h"
|
||||
#include "RefCounted.h"
|
||||
#include "galaxy/AtmosphereParameters.h"
|
||||
#include "graphics/Frustum.h"
|
||||
#include "graphics/Graphics.h"
|
||||
|
@ -17,11 +16,8 @@
|
|||
#include "graphics/Texture.h"
|
||||
#include "graphics/VertexArray.h"
|
||||
#include "graphics/opengl/GenGasGiantColourMaterial.h"
|
||||
#include "libs.h"
|
||||
#include "perlin.h"
|
||||
#include "vcacheopt/vcacheopt.h"
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
|
||||
RefCountedPtr<GasPatchContext> GasGiant::s_patchContext;
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include "BaseSphere.h"
|
||||
#include "GasGiantJobs.h"
|
||||
#include "JobQueue.h"
|
||||
#include "graphics/Material.h"
|
||||
#include "terrain/Terrain.h"
|
||||
#include "vector3.h"
|
||||
|
||||
#include <deque>
|
||||
|
@ -17,6 +15,7 @@ namespace Graphics {
|
|||
class Renderer;
|
||||
class RenderState;
|
||||
class RenderTarget;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
class SystemBody;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "graphics/Graphics.h"
|
||||
#include "graphics/Material.h"
|
||||
#include "graphics/Renderer.h"
|
||||
#include "graphics/VertexBuffer.h"
|
||||
#include "perlin.h"
|
||||
#include "vcacheopt/vcacheopt.h"
|
||||
#include <algorithm>
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
|
||||
#include <SDL_stdinc.h>
|
||||
|
||||
#include "Color.h"
|
||||
#include "GeoPatchID.h"
|
||||
#include "JobQueue.h"
|
||||
#include "RefCounted.h"
|
||||
#include "matrix4x4.h"
|
||||
#include "vector3.h"
|
||||
#include "graphics/VertexBuffer.h"
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
|
||||
//#define DEBUG_BOUNDING_SPHERES
|
||||
|
||||
|
@ -25,6 +27,7 @@ namespace Graphics {
|
|||
namespace Graphics {
|
||||
class Renderer;
|
||||
class Frustum;
|
||||
class VertexBuffer;
|
||||
}
|
||||
|
||||
class GeoPatchContext;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace Graphics {
|
||||
class Renderer;
|
||||
class Texture;
|
||||
}
|
||||
|
||||
class SystemBody;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef HEATGRADIENTPAR_H_INCLUDED
|
||||
#define HEATGRADIENTPAR_H_INCLUDED
|
||||
|
||||
struct HeatGradientParameters_t {
|
||||
matrix3x3f heatingMatrix;
|
||||
vector3f heatingNormal; // normalised
|
||||
float heatingAmount; // 0.0 to 1.0 used for `u` component of heatGradient texture
|
||||
};
|
||||
|
||||
|
||||
#endif // HEATGRADIENTPAR_H_INCLUDED
|
|
@ -6,10 +6,7 @@
|
|||
#include "Frame.h"
|
||||
#include "Game.h"
|
||||
#include "HyperspaceCloud.h"
|
||||
#include "LuaConstants.h"
|
||||
#include "LuaMissile.h"
|
||||
#include "LuaObject.h"
|
||||
#include "LuaUtils.h"
|
||||
#include "LuaVector.h"
|
||||
#include "Missile.h"
|
||||
#include "Pi.h"
|
||||
|
|
|
@ -288,7 +288,6 @@ static bool get_cached(lua_State *L, const std::string &name)
|
|||
#include <algorithm>
|
||||
static std::string table_path_to_file_name(const std::string &path)
|
||||
{
|
||||
const char separator = '.';
|
||||
std::string out = path;
|
||||
|
||||
// If we have an old-style 'module/path/file.lua' path, return it normalized.
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "Ship.h"
|
||||
#include "ShipAICmd.h"
|
||||
#include "Space.h"
|
||||
#include "collider/CollisionContact.h"
|
||||
|
||||
|
||||
Missile::Missile(const ShipType::Id &shipId, Body *owner, int power)
|
||||
{
|
||||
|
|
|
@ -3,19 +3,23 @@
|
|||
|
||||
#include "ModelBody.h"
|
||||
|
||||
#include "Camera.h"
|
||||
#include "Frame.h"
|
||||
#include "GameSaveError.h"
|
||||
#include "Json.h"
|
||||
#include "Pi.h"
|
||||
#include "Planet.h"
|
||||
#include "Shields.h"
|
||||
#include "Space.h"
|
||||
#include "collider/collider.h"
|
||||
#include "collider/CollisionSpace.h"
|
||||
#include "collider/Geom.h"
|
||||
#include "galaxy/SystemBody.h"
|
||||
#include "scenegraph/Animation.h"
|
||||
#include "scenegraph/CollisionGeometry.h"
|
||||
#include "scenegraph/NodeVisitor.h"
|
||||
#include "scenegraph/SceneGraph.h"
|
||||
|
||||
class Space;
|
||||
|
||||
class DynGeomFinder : public SceneGraph::NodeVisitor {
|
||||
public:
|
||||
std::vector<SceneGraph::CollisionGeometry *> results;
|
||||
|
|
11
src/Pi.cpp
11
src/Pi.cpp
|
@ -6,7 +6,6 @@
|
|||
#include "Pi.h"
|
||||
|
||||
#include "BaseSphere.h"
|
||||
#include "CargoBody.h"
|
||||
#include "CityOnPlanet.h"
|
||||
#include "DeathView.h"
|
||||
#include "EnumStrings.h"
|
||||
|
@ -34,13 +33,9 @@
|
|||
#include "LuaJson.h"
|
||||
#include "LuaLang.h"
|
||||
#include "LuaManager.h"
|
||||
#include "LuaMissile.h"
|
||||
#include "LuaMusic.h"
|
||||
#include "LuaNameGen.h"
|
||||
#include "LuaPiGui.h"
|
||||
#include "LuaRef.h"
|
||||
#include "LuaSerializer.h"
|
||||
#include "LuaServerAgent.h"
|
||||
#include "LuaShipDef.h"
|
||||
#include "LuaSpace.h"
|
||||
#include "LuaTimer.h"
|
||||
|
@ -57,12 +52,9 @@
|
|||
#endif
|
||||
#include "Beam.h"
|
||||
#include "PiGui.h"
|
||||
#include "Planet.h"
|
||||
#include "Player.h"
|
||||
#include "Projectile.h"
|
||||
#include "SDLWrappers.h"
|
||||
#include "SectorView.h"
|
||||
#include "ServerAgent.h"
|
||||
#include "Sfx.h"
|
||||
#include "Shields.h"
|
||||
#include "ShipCpanel.h"
|
||||
|
@ -77,7 +69,6 @@
|
|||
#include "UIView.h"
|
||||
#include "WorldView.h"
|
||||
#include "galaxy/GalaxyGenerator.h"
|
||||
#include "galaxy/StarSystem.h"
|
||||
#include "gameui/Lua.h"
|
||||
#include "libs.h"
|
||||
#include "pigui/PiGuiLua.h"
|
||||
|
@ -96,8 +87,6 @@
|
|||
|
||||
#include "scenegraph/Lua.h"
|
||||
#include "versioningInfo.h"
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#ifdef PROFILE_LUA_TIME
|
||||
#include <time.h>
|
||||
|
|
5
src/Pi.h
5
src/Pi.h
|
@ -13,7 +13,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Frame;
|
||||
class Game;
|
||||
|
||||
class GameConfig;
|
||||
|
@ -25,12 +24,8 @@ class ModelCache;
|
|||
class ObjectViewerView;
|
||||
class PiGui;
|
||||
class Player;
|
||||
class Ship;
|
||||
class SpaceStation;
|
||||
class StarSystem;
|
||||
class SystemPath;
|
||||
class TransferPlanner;
|
||||
class UIView;
|
||||
class View;
|
||||
class SDLGraphics;
|
||||
class LuaSerializer;
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
#include "Sfx.h"
|
||||
#include "Ship.h"
|
||||
#include "Space.h"
|
||||
#include "collider/collider.h"
|
||||
#include "collider/CollisionContact.h"
|
||||
#include "collider/CollisionSpace.h"
|
||||
#include "galaxy/StarSystem.h"
|
||||
#include "graphics/Graphics.h"
|
||||
#include "graphics/Material.h"
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#define _PROJECTILE_H
|
||||
|
||||
#include "Body.h"
|
||||
#include "graphics/Material.h"
|
||||
|
||||
struct ProjectileData {
|
||||
ProjectileData() :
|
||||
|
@ -30,6 +29,7 @@ struct ProjectileData {
|
|||
class Frame;
|
||||
|
||||
namespace Graphics {
|
||||
class Material;
|
||||
class Renderer;
|
||||
class RenderState;
|
||||
class VertexArray;
|
||||
|
|
37
src/Sfx.cpp
37
src/Sfx.cpp
|
@ -41,12 +41,6 @@ Graphics::RenderState *SfxManager::additiveAlphaState = nullptr;
|
|||
Graphics::RenderState *SfxManager::alphaOneState = nullptr;
|
||||
SfxManager::MaterialData SfxManager::m_materialData[TYPE_NONE];
|
||||
|
||||
Sfx::Sfx() :
|
||||
m_speed(200.0f),
|
||||
m_type(TYPE_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
Sfx::Sfx(const vector3d &pos, const vector3d &vel, const float speed, const SFX_TYPE type) :
|
||||
m_pos(pos),
|
||||
m_vel(vel),
|
||||
|
@ -56,6 +50,20 @@ Sfx::Sfx(const vector3d &pos, const vector3d &vel, const float speed, const SFX_
|
|||
{
|
||||
}
|
||||
|
||||
Sfx::Sfx(const Json &jsonObj)
|
||||
{
|
||||
try {
|
||||
Json sfxObj = jsonObj["sfx"];
|
||||
|
||||
m_pos = jsonObj["pos"];
|
||||
m_vel = jsonObj["vel"];
|
||||
m_age = sfxObj["age"];
|
||||
m_type = sfxObj["type"];
|
||||
} catch (Json::type_error &) {
|
||||
throw SavedGameCorruptException();
|
||||
}
|
||||
}
|
||||
|
||||
Sfx::Sfx(const Sfx &b) :
|
||||
m_pos(b.m_pos),
|
||||
m_vel(b.m_vel),
|
||||
|
@ -77,20 +85,6 @@ void Sfx::SaveToJson(Json &jsonObj)
|
|||
jsonObj["sfx"] = sfxObj; // Add sfx object to supplied object.
|
||||
}
|
||||
|
||||
void Sfx::LoadFromJson(const Json &jsonObj)
|
||||
{
|
||||
try {
|
||||
Json sfxObj = jsonObj["sfx"];
|
||||
|
||||
m_pos = jsonObj["pos"];
|
||||
m_vel = jsonObj["vel"];
|
||||
m_age = sfxObj["age"];
|
||||
m_type = sfxObj["type"];
|
||||
} catch (Json::type_error &) {
|
||||
throw SavedGameCorruptException();
|
||||
}
|
||||
}
|
||||
|
||||
void Sfx::SetPosition(const vector3d &p)
|
||||
{
|
||||
m_pos = p;
|
||||
|
@ -160,8 +154,7 @@ void SfxManager::FromJson(const Json &jsonObj, Frame *f)
|
|||
|
||||
if (sfxArray.size()) f->m_sfx.reset(new SfxManager);
|
||||
for (unsigned int i = 0; i < sfxArray.size(); ++i) {
|
||||
Sfx inst;
|
||||
inst.LoadFromJson(sfxArray[i]);
|
||||
Sfx inst(sfxArray[i]);
|
||||
f->m_sfx->AddInstance(inst);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,9 @@ enum SFX_TYPE {
|
|||
class Sfx {
|
||||
public:
|
||||
friend class SfxManager;
|
||||
Sfx();
|
||||
Sfx() = delete;
|
||||
Sfx(const vector3d &pos, const vector3d &vel, const float speed, const SFX_TYPE type);
|
||||
Sfx(const Json &jsonObj);
|
||||
Sfx(const Sfx &);
|
||||
void SetPosition(const vector3d &p);
|
||||
const vector3d &GetPosition() const { return m_pos; }
|
||||
|
@ -38,7 +39,6 @@ public:
|
|||
private:
|
||||
void TimeStepUpdate(const float timeStep);
|
||||
void SaveToJson(Json &jsonObj);
|
||||
void LoadFromJson(const Json &jsonObj);
|
||||
|
||||
vector3d m_pos;
|
||||
vector3d m_vel;
|
||||
|
|
|
@ -10,14 +10,17 @@
|
|||
#include "Game.h"
|
||||
#include "GameLog.h"
|
||||
#include "GameSaveError.h"
|
||||
#include "HeatGradientPar.h"
|
||||
#include "HyperspaceCloud.h"
|
||||
#include "Lang.h"
|
||||
#include "LuaEvent.h"
|
||||
#include "LuaObject.h"
|
||||
#include "LuaUtils.h"
|
||||
#include "Missile.h"
|
||||
#include "NavLights.h"
|
||||
#include "Planet.h"
|
||||
#include "Player.h" // <-- Here only for 1 occurence of "Pi::player" in Ship::Explode
|
||||
#include "Sensors.h"
|
||||
#include "Sfx.h"
|
||||
#include "Shields.h"
|
||||
#include "ShipAICmd.h"
|
||||
|
@ -25,6 +28,7 @@
|
|||
#include "SpaceStation.h"
|
||||
#include "StringF.h"
|
||||
#include "WorldView.h"
|
||||
#include "collider/CollisionContact.h"
|
||||
#include "graphics/TextureBuilder.h"
|
||||
#include "scenegraph/Animation.h"
|
||||
#include "scenegraph/MatrixTransform.h"
|
||||
|
|
13
src/Ship.h
13
src/Ship.h
|
@ -8,8 +8,6 @@
|
|||
|
||||
#include "DynamicBody.h"
|
||||
#include "LuaRef.h"
|
||||
#include "NavLights.h"
|
||||
#include "Sensors.h"
|
||||
#include "ShipType.h"
|
||||
#include "galaxy/SystemPath.h"
|
||||
#include "scenegraph/ModelSkin.h"
|
||||
|
@ -24,20 +22,19 @@ class CargoBody;
|
|||
class SpaceStation;
|
||||
class HyperspaceCloud;
|
||||
class Missile;
|
||||
class NavLights;
|
||||
class Planet;
|
||||
class Sensors;
|
||||
class ShipController;
|
||||
class Space;
|
||||
|
||||
struct CollisionContact;
|
||||
struct HeatGradientParameters_t;
|
||||
|
||||
namespace Graphics {
|
||||
class Renderer;
|
||||
}
|
||||
|
||||
struct HeatGradientParameters_t {
|
||||
matrix3x3f heatingMatrix;
|
||||
vector3f heatingNormal; // normalised
|
||||
float heatingAmount; // 0.0 to 1.0 used for `u` component of heatGradient texture
|
||||
};
|
||||
|
||||
struct shipstats_t {
|
||||
int used_capacity;
|
||||
int used_cargo;
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#include "Player.h"
|
||||
#include "SpaceStation.h"
|
||||
#include "Star.h"
|
||||
#include "collider/collider.h"
|
||||
#include "collider/CollisionContact.h"
|
||||
#include "collider/CollisionSpace.h"
|
||||
#include "galaxy/Galaxy.h"
|
||||
#include "graphics/Graphics.h"
|
||||
#include <algorithm>
|
||||
|
@ -951,7 +952,7 @@ static void hitCallback(CollisionContact *c)
|
|||
mover->SetPosition(mover->GetPosition() + correction);
|
||||
|
||||
const float reduction = std::max(1 - coeff_slide * c->timestep, 0.0);
|
||||
vector3d final_vel = linVel1 * (1 - coeff_slide * c->timestep) + force * invMass1;
|
||||
vector3d final_vel = linVel1 * reduction + force * invMass1;
|
||||
if (final_vel.LengthSqr() < 0.1) final_vel = vector3d(0.0);
|
||||
|
||||
mover->SetVelocity(final_vel);
|
||||
|
|
|
@ -8,15 +8,12 @@
|
|||
#include "IterationProxy.h"
|
||||
#include "Object.h"
|
||||
#include "RefCounted.h"
|
||||
#include "galaxy/GalaxyCache.h"
|
||||
#include "galaxy/StarSystem.h"
|
||||
#include "vector3.h"
|
||||
#include <list>
|
||||
|
||||
class Body;
|
||||
class Frame;
|
||||
class Ship;
|
||||
class HyperspaceCloud;
|
||||
class Game;
|
||||
|
||||
class Space {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "SpaceStation.h"
|
||||
|
||||
#include "Camera.h"
|
||||
#include "CityOnPlanet.h"
|
||||
#include "Frame.h"
|
||||
#include "Game.h"
|
||||
|
@ -11,13 +12,13 @@
|
|||
#include "Json.h"
|
||||
#include "Lang.h"
|
||||
#include "LuaEvent.h"
|
||||
#include "NavLights.h"
|
||||
#include "Pi.h"
|
||||
#include "Planet.h"
|
||||
#include "Player.h"
|
||||
#include "Ship.h"
|
||||
#include "Space.h"
|
||||
#include "StringF.h"
|
||||
#include "graphics/Graphics.h"
|
||||
#include "graphics/Renderer.h"
|
||||
#include "scenegraph/Animation.h"
|
||||
#include "scenegraph/MatrixTransform.h"
|
||||
|
|
|
@ -5,22 +5,24 @@
|
|||
#define _SPACESTATION_H
|
||||
|
||||
#include "ModelBody.h"
|
||||
#include "NavLights.h"
|
||||
#include "Quaternion.h"
|
||||
#include "SpaceStationType.h"
|
||||
|
||||
#define MAX_DOCKING_PORTS 240 //256-(0x10), 0x10 is used because the collision surfaces use it as an identifying flag
|
||||
|
||||
class Body;
|
||||
class Camera;
|
||||
class CityOnPlanet;
|
||||
class CollMeshSet;
|
||||
class Planet;
|
||||
class Frame;
|
||||
class NavLights;
|
||||
class Ship;
|
||||
class SpaceStation;
|
||||
class Space;
|
||||
class SystemBody;
|
||||
|
||||
namespace Graphics {
|
||||
class Renderer;
|
||||
}
|
||||
|
||||
namespace SceneGraph {
|
||||
class Animation;
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "Star.h"
|
||||
#include <memory>
|
||||
|
||||
#include "Pi.h"
|
||||
#include "galaxy/SystemBody.h"
|
||||
#include "galaxy/StarSystem.h"
|
||||
#include "graphics/RenderState.h"
|
||||
#include "graphics/Renderer.h"
|
||||
#include "graphics/VertexArray.h"
|
||||
#include "graphics/VertexBuffer.h"
|
||||
|
||||
Star::Star(SystemBody *sbody) :
|
||||
TerrainBody(sbody)
|
||||
|
@ -21,6 +23,10 @@ Star::Star(const Json &jsonObj, Space *space) :
|
|||
InitStar();
|
||||
}
|
||||
|
||||
Star::~Star()
|
||||
{
|
||||
}
|
||||
|
||||
void Star::InitStar()
|
||||
{
|
||||
// this one should be atmosphere radius when stars have atmosphere
|
||||
|
|
|
@ -5,11 +5,15 @@
|
|||
#define _STAR_H
|
||||
|
||||
#include "TerrainBody.h"
|
||||
#include "graphics/VertexBuffer.h"
|
||||
|
||||
class Camera;
|
||||
class Space;
|
||||
class SystemBody;
|
||||
|
||||
namespace Graphics {
|
||||
class Renderer;
|
||||
class RenderState;
|
||||
class VertexBuffer;
|
||||
} // namespace Graphics
|
||||
|
||||
class Star : public TerrainBody {
|
||||
|
@ -18,7 +22,7 @@ public:
|
|||
Star() = delete;
|
||||
Star(SystemBody *sbody);
|
||||
Star(const Json &jsonObj, Space *space);
|
||||
virtual ~Star(){};
|
||||
virtual ~Star();
|
||||
|
||||
virtual void Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) override;
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "StringF.h"
|
||||
#include "galaxy/Factions.h"
|
||||
#include "galaxy/Galaxy.h"
|
||||
#include "galaxy/Sector.h"
|
||||
#include "galaxy/SystemPath.h"
|
||||
#include "galaxy/Polit.h"
|
||||
#include "graphics/Drawables.h"
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#ifndef _SYSTEMINFOVIEW_H
|
||||
#define _SYSTEMINFOVIEW_H
|
||||
|
||||
#include "Color.h"
|
||||
#include "galaxy/SystemPath.h"
|
||||
#include "gui/Gui.h"
|
||||
#include "libs.h"
|
||||
#include "gui/GuiImageRadioButton.h"
|
||||
|
||||
#include "UIView.h"
|
||||
#include <vector>
|
||||
|
@ -14,8 +14,10 @@
|
|||
class Game;
|
||||
class StarSystem;
|
||||
class SystemBody;
|
||||
|
||||
namespace Graphics {
|
||||
class Renderer;
|
||||
class RenderState;
|
||||
}
|
||||
|
||||
class SystemInfoView : public UIView {
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
|
||||
#include "SystemView.h"
|
||||
#include "AnimationCurves.h"
|
||||
#include "FloatComparison.h"
|
||||
#include "Frame.h"
|
||||
#include "Game.h"
|
||||
#include "GameLog.h"
|
||||
#include "Lang.h"
|
||||
#include "LuaObject.h"
|
||||
#include "MathUtil.h"
|
||||
#include "Pi.h"
|
||||
#include "Player.h"
|
||||
#include "SectorView.h"
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
#ifndef _SYSTEMVIEW_H
|
||||
#define _SYSTEMVIEW_H
|
||||
|
||||
#include "Color.h"
|
||||
#include "UIView.h"
|
||||
#include "graphics/Drawables.h"
|
||||
#include "gui/Gui.h"
|
||||
#include "libs.h"
|
||||
#include "matrix4x4.h"
|
||||
#include "vector3.h"
|
||||
|
||||
class StarSystem;
|
||||
class SystemBody;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "Json.h"
|
||||
#include "Space.h"
|
||||
#include "galaxy/SystemBody.h"
|
||||
#include "graphics/Graphics.h"
|
||||
#include "graphics/Renderer.h"
|
||||
|
||||
TerrainBody::TerrainBody(SystemBody *sbody) :
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
#ifndef _TERRAINBODY_H
|
||||
#define _TERRAINBODY_H
|
||||
|
||||
#include "BaseSphere.h"
|
||||
#include "Body.h"
|
||||
#include "JsonFwd.h"
|
||||
#include "matrix4x4.h"
|
||||
|
||||
class BaseSphere;
|
||||
class Camera;
|
||||
class Frame;
|
||||
class Space;
|
||||
class SystemBody;
|
||||
|
||||
namespace Graphics {
|
||||
|
|
|
@ -14,21 +14,16 @@
|
|||
#include "Pi.h"
|
||||
#include "Player.h"
|
||||
#include "SectorView.h"
|
||||
#include "Sensors.h"
|
||||
#include "SpeedLines.h"
|
||||
#include "StringF.h"
|
||||
#include "graphics/Drawables.h"
|
||||
#include "graphics/Frustum.h"
|
||||
#include "graphics/Graphics.h"
|
||||
#include "graphics/Renderer.h"
|
||||
#include "graphics/TextureBuilder.h"
|
||||
#include "matrix4x4.h"
|
||||
#include "ship/PlayerShipController.h"
|
||||
#include "sound/Sound.h"
|
||||
#include "ui/Align.h"
|
||||
#include "ui/Context.h"
|
||||
#include "ui/Label.h"
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include "ui/Widget.h"
|
||||
|
||||
const double WorldView::PICK_OBJECT_RECT_SIZE = 20.0;
|
||||
namespace {
|
||||
|
@ -297,7 +292,6 @@ void WorldView::Update()
|
|||
assert(Pi::player);
|
||||
assert(!Pi::player->IsDead());
|
||||
|
||||
const double frameTime = Pi::GetFrameTime();
|
||||
// show state-appropriate buttons
|
||||
RefreshButtonStateAndVisibility();
|
||||
|
||||
|
|
|
@ -4,16 +4,13 @@
|
|||
#ifndef _WORLDVIEW_H
|
||||
#define _WORLDVIEW_H
|
||||
|
||||
#include "Camera.h"
|
||||
#include "SpeedLines.h"
|
||||
#include "UIView.h"
|
||||
#include "gui/GuiWidget.h"
|
||||
#include "ship/ShipViewController.h"
|
||||
|
||||
class Body;
|
||||
class Frame;
|
||||
class LabelSet;
|
||||
class Ship;
|
||||
class Camera;
|
||||
class SpeedLines;
|
||||
class NavTunnelWidget;
|
||||
class Game;
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "CollisionSpace.h"
|
||||
|
||||
#include "../libs.h"
|
||||
#include "CollisionContact.h"
|
||||
#include "Geom.h"
|
||||
#include "GeomTree.h"
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include "BVHTree.h"
|
||||
#include "GeomTree.h"
|
||||
#include "collider.h"
|
||||
#include "CollisionContact.h"
|
||||
#include "CollisionSpace.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#ifndef _GEOMTREE_H
|
||||
#define _GEOMTREE_H
|
||||
|
||||
#include "CollisionContact.h"
|
||||
#include "libs.h"
|
||||
|
||||
namespace Serializer {
|
||||
|
@ -25,6 +24,8 @@ class GeomTree {
|
|||
public:
|
||||
GeomTree(const int numVerts, const int numTris, const std::vector<vector3f> &vertices, const Uint32 *indices, const Uint32 *triflags);
|
||||
GeomTree(Serializer::Reader &rd);
|
||||
void Save(Serializer::Writer &wr) const;
|
||||
|
||||
~GeomTree();
|
||||
|
||||
const Aabb &GetAabb() const { return m_aabb; }
|
||||
|
@ -63,8 +64,6 @@ public:
|
|||
int GetNumVertices() const { return m_numVertices; }
|
||||
int GetNumTris() const { return m_numTris; }
|
||||
|
||||
void Save(Serializer::Writer &wr) const;
|
||||
|
||||
private:
|
||||
void RayTriIntersect(int numRays, const vector3f &origin, const vector3f *dirs, int triIdx, isect_t *isects) const;
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "MultiMaterial.h"
|
||||
|
||||
#include "RendererGL.h"
|
||||
#include "Ship.h"
|
||||
#include "HeatGradientPar.h"
|
||||
#include "StringF.h"
|
||||
#include "TextureGL.h"
|
||||
#include "graphics/Graphics.h"
|
||||
|
|
|
@ -147,7 +147,6 @@ void BinaryConverter::Save(const std::string &filename, const std::string &savep
|
|||
|
||||
// compress in memory, write to open file
|
||||
size_t outSize = 0;
|
||||
size_t nwritten = 0;
|
||||
const std::string &data = wr.GetData();
|
||||
try {
|
||||
std::unique_ptr<char> compressedData = lz4::CompressLZ4(data, 6, outSize);
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||
|
||||
#include "CollisionVisitor.h"
|
||||
#include "CollMesh.h"
|
||||
|
||||
#include "CollisionGeometry.h"
|
||||
#include "Group.h"
|
||||
#include "MatrixTransform.h"
|
||||
#include "StaticGeometry.h"
|
||||
#include "collider/GeomTree.h"
|
||||
|
||||
namespace SceneGraph {
|
||||
CollisionVisitor::CollisionVisitor() :
|
||||
|
|
|
@ -284,10 +284,10 @@ namespace SceneGraph {
|
|||
if (!m_collMesh) return;
|
||||
|
||||
if (!m_collisionMeshVB.Valid()) {
|
||||
const std::vector<vector3f> &vertices = m_collMesh->GetGeomTree()->GetVertices();
|
||||
const Uint32 *indices = m_collMesh->GetGeomTree()->GetIndices();
|
||||
const unsigned int *triFlags = m_collMesh->GetGeomTree()->GetTriFlags();
|
||||
const unsigned int numIndices = m_collMesh->GetGeomTree()->GetNumTris() * 3;
|
||||
const std::vector<vector3f> &vertices = m_collMesh->GetGeomTreeVertices();
|
||||
const Uint32 *indices = m_collMesh->GetGeomTreeIndices();
|
||||
const unsigned int *triFlags = m_collMesh->GetGeomTreeTriFlags();
|
||||
const unsigned int numIndices = m_collMesh->GetGeomTreeNumTris() * 3;
|
||||
|
||||
Graphics::VertexArray va(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_DIFFUSE, numIndices * 3);
|
||||
int trindex = -1;
|
||||
|
|
Loading…
Reference in New Issue