1
0
forked from 0ad/0ad

Remove leftover terrain-based movement cost code.

6581796103 removed the ability for terrain to affect movement speed. The
JPS pathfinder cannot support it, and the approach was poor anyways,
coupling rendering data with simulation data.
This lets us remove the dependency on CTerrainTextureManager everywhere.

Tested by: langbart
Differential Revision: https://code.wildfiregames.com/D4459
This was SVN commit r26269.
This commit is contained in:
wraitii 2022-01-29 08:22:28 +00:00
parent 1d7eb7492e
commit 410d2e883a
21 changed files with 36 additions and 103 deletions

View File

@ -5,6 +5,6 @@
<texture name="normTex" file="types/medit_city_tile_norm.png"/> <texture name="normTex" file="types/medit_city_tile_norm.png"/>
<texture name="specTex" file="types/medit_city_tile_spec.png"/> <texture name="specTex" file="types/medit_city_tile_spec.png"/>
</textures> </textures>
<props groups="city" movementclass="city" mmap="230 227 198" angle="45.0" size="18.0"/> <props groups="city" mmap="230 227 198" angle="45.0" size="18.0"/>
<material>terrain_norm_spec.xml</material> <material>terrain_norm_spec.xml</material>
</terrain> </terrain>

View File

@ -5,6 +5,6 @@
<texture name="normTex" file="types/temp_road_broken_norm.png"/> <texture name="normTex" file="types/temp_road_broken_norm.png"/>
<texture name="specTex" file="types/temp_road_broken_spec.png"/> <texture name="specTex" file="types/temp_road_broken_spec.png"/>
</textures> </textures>
<props groups="city" movementclass="city" mmap="230 227 198"/> <props groups="city" mmap="230 227 198"/>
<material>terrain_norm_spec.xml</material> <material>terrain_norm_spec.xml</material>
</terrain> </terrain>

View File

@ -5,6 +5,6 @@
<texture name="normTex" file="types/savanna_tile_a_norm.png"/> <texture name="normTex" file="types/savanna_tile_a_norm.png"/>
<texture name="specTex" file="types/savanna_tile_a_spec.png"/> <texture name="specTex" file="types/savanna_tile_a_spec.png"/>
</textures> </textures>
<props groups="city" movementclass="city" mmap="230 227 198" angle="45.0"/> <props groups="city" mmap="230 227 198" angle="45.0"/>
<material>terrain_norm_spec.xml</material> <material>terrain_norm_spec.xml</material>
</terrain> </terrain>

View File

@ -5,6 +5,6 @@
<texture name="normTex" file="types/savanna_tile_a_norm.png"/> <texture name="normTex" file="types/savanna_tile_a_norm.png"/>
<texture name="specTex" file="types/savanna_tile_a_spec.png"/> <texture name="specTex" file="types/savanna_tile_a_spec.png"/>
</textures> </textures>
<props groups="city" movementclass="city" mmap="230 227 198" angle="45.0"/> <props groups="city" mmap="230 227 198" angle="45.0"/>
<material>terrain_norm_spec.xml</material> <material>terrain_norm_spec.xml</material>
</terrain> </terrain>

View File

@ -3,6 +3,6 @@
<textures> <textures>
<texture name="baseTex" file="types/temp_road_muddy.png"/> <texture name="baseTex" file="types/temp_road_muddy.png"/>
</textures> </textures>
<props groups="city" movementclass="city" mmap="230 227 198"/> <props groups="city" mmap="230 227 198"/>
<material>terrain_base.xml</material> <material>terrain_base.xml</material>
</terrain> </terrain>

View File

@ -3,6 +3,6 @@
<textures> <textures>
<texture name="baseTex" file="types/tropic_citytile_a.png"/> <texture name="baseTex" file="types/tropic_citytile_a.png"/>
</textures> </textures>
<props groups="city" movementclass="city" mmap="230 227 198"/> <props groups="city" mmap="230 227 198"/>
<material>terrain_base.xml</material> <material>terrain_base.xml</material>
</terrain> </terrain>

View File

@ -38,9 +38,6 @@
<data type="float"/> <data type="float"/>
</attribute> </attribute>
</optional> </optional>
<optional>
<attribute name="movementclass"/>
</optional>
</interleave> </interleave>
</element> </element>
</element> </element>

View File

@ -59,9 +59,6 @@
<data type="float"/> <data type="float"/>
</attribute> </attribute>
</optional> </optional>
<optional>
<attribute name="movementclass"/>
</optional>
</interleave> </interleave>
</element> </element>
</zeroOrMore> </zeroOrMore>

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -247,9 +247,11 @@ int CMapReader::UnpackTerrain()
CStr texturename; CStr texturename;
unpacker.UnpackString(texturename); unpacker.UnpackString(texturename);
ENSURE(CTerrainTextureManager::IsInitialised()); // we need this for the terrain properties (even when graphics are disabled) if(CTerrainTextureManager::IsInitialised())
CTerrainTextureEntry* texentry = g_TexMan.FindTexture(texturename); {
m_TerrainTextures.push_back(texentry); CTerrainTextureEntry* texentry = g_TexMan.FindTexture(texturename);
m_TerrainTextures.push_back(texentry);
}
cur_terrain_tex++; cur_terrain_tex++;
LDR_CHECK_TIMEOUT(cur_terrain_tex, num_terrain_tex); LDR_CHECK_TIMEOUT(cur_terrain_tex, num_terrain_tex);
@ -1354,9 +1356,11 @@ if (!Script::GetProperty(rq, val, #prop, out))\
while (cur_terrain_tex < num_terrain_tex) while (cur_terrain_tex < num_terrain_tex)
{ {
ENSURE(CTerrainTextureManager::IsInitialised()); // we need this for the terrain properties (even when graphics are disabled) if (CTerrainTextureManager::IsInitialised())
CTerrainTextureEntry* texentry = g_TexMan.FindTexture(textureNames[cur_terrain_tex]); {
m_TerrainTextures.push_back(texentry); CTerrainTextureEntry* texentry = g_TexMan.FindTexture(textureNames[cur_terrain_tex]);
m_TerrainTextures.push_back(texentry);
}
cur_terrain_tex++; cur_terrain_tex++;
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -95,17 +95,6 @@ bool CTerrain::Initialize(ssize_t patchesPerSide, const u16* data)
return true; return true;
} }
///////////////////////////////////////////////////////////////////////////////
CStr8 CTerrain::GetMovementClass(ssize_t i, ssize_t j) const
{
CMiniPatch* tile = GetTile(i, j);
if (tile && tile->GetTextureEntry())
return tile->GetTextureEntry()->GetProperties().GetMovementClass();
return "default";
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// CalcPosition: calculate the world space position of the vertex at (i,j) // CalcPosition: calculate the world space position of the vertex at (i,j)
// If i,j is off the map, it acts as if the edges of the terrain are extended // If i,j is off the map, it acts as if the edges of the terrain are extended

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -79,8 +79,6 @@ public:
&& (z >= GetMinZ()) && (z < GetMaxZ())); && (z >= GetMinZ()) && (z < GetMaxZ()));
} }
CStr8 GetMovementClass(ssize_t i, ssize_t j) const;
float GetVertexGroundLevel(ssize_t i, ssize_t j) const; float GetVertexGroundLevel(ssize_t i, ssize_t j) const;
fixed GetVertexGroundLevelFixed(ssize_t i, ssize_t j) const; fixed GetVertexGroundLevelFixed(ssize_t i, ssize_t j) const;
float GetExactGroundLevel(float x, float z) const; float GetExactGroundLevel(float x, float z) const;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -35,8 +35,7 @@ CTerrainProperties::CTerrainProperties(CTerrainPropertiesPtr parent):
m_BaseColor(0), m_BaseColor(0),
m_HasBaseColor(false), m_HasBaseColor(false),
m_TextureAngle((float)M_PI / 4.f), m_TextureAngle((float)M_PI / 4.f),
m_TextureSize(32.f), m_TextureSize(32.f)
m_MovementClass("default")
{ {
if (m_pParent) if (m_pParent)
m_Groups = m_pParent->m_Groups; m_Groups = m_pParent->m_Groups;
@ -95,7 +94,6 @@ void CTerrainProperties::LoadXml(XMBElement node, CXeromyces *pFile, const VfsPa
// Terrain Attribs // Terrain Attribs
ATTR(mmap); ATTR(mmap);
ATTR(groups); ATTR(groups);
ATTR(movementclass);
ATTR(angle); ATTR(angle);
ATTR(size); ATTR(size);
#undef ELMT #undef ELMT
@ -136,10 +134,6 @@ void CTerrainProperties::LoadXml(XMBElement node, CXeromyces *pFile, const VfsPa
{ {
m_TextureSize = attr.Value.ToFloat(); m_TextureSize = attr.Value.ToFloat();
} }
else if (attr.Name == attr_movementclass)
{
m_MovementClass = attr.Value;
}
} }
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -55,8 +55,6 @@ private:
u32 m_BaseColor; u32 m_BaseColor;
bool m_HasBaseColor; bool m_HasBaseColor;
CStr m_MovementClass;
// Orientation of texture (in radians) (default pi/4 = 45 degrees) // Orientation of texture (in radians) (default pi/4 = 45 degrees)
float m_TextureAngle; float m_TextureAngle;
@ -103,11 +101,6 @@ public:
return m_TextureSize; return m_TextureSize;
} }
CStr GetMovementClass() const
{
return m_MovementClass;
}
const GroupVector &GetGroups() const const GroupVector &GetGroups() const
{ {
return m_Groups; return m_Groups;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -44,11 +44,6 @@ public:
TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir() / "_testcache" / "", 0, VFS_MAX_PRIORITY)); TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir() / "_testcache" / "", 0, VFS_MAX_PRIORITY));
CXeromyces::Startup(); CXeromyces::Startup();
// Need some stuff for terrain movement costs:
// (TODO: this ought to be independent of any graphics code)
new CTerrainTextureManager;
g_TexMan.LoadTerrainTextures();
enet_initialize(); enet_initialize();
} }
@ -56,8 +51,6 @@ public:
{ {
enet_deinitialize(); enet_deinitialize();
delete &g_TexMan;
CXeromyces::Terminate(); CXeromyces::Terminate();
g_VFS.reset(); g_VFS.reset();
DeleteDirectory(DataDir()/"_testcache"); DeleteDirectory(DataDir()/"_testcache");

View File

@ -435,10 +435,6 @@ void Shutdown(int flags)
ShutdownPs(); ShutdownPs();
TIMER_BEGIN(L"shutdown TexMan");
delete &g_TexMan;
TIMER_END(L"shutdown TexMan");
if (hasRenderer) if (hasRenderer)
{ {
TIMER_BEGIN(L"shutdown Renderer"); TIMER_BEGIN(L"shutdown Renderer");
@ -826,10 +822,6 @@ void InitGraphics(const CmdLineArgs& args, int flags, const std::vector<CStr>& i
void InitNonVisual(const CmdLineArgs& args) void InitNonVisual(const CmdLineArgs& args)
{ {
// Need some stuff for terrain movement costs:
// (TODO: this ought to be independent of any graphics code)
new CTerrainTextureManager;
g_TexMan.LoadTerrainTextures();
Autostart(args); Autostart(args);
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -248,11 +248,6 @@ void CReplayPlayer::Replay(const bool serializationtest, const int rejointesttur
if (ooslog) if (ooslog)
g_Game->GetSimulation2()->EnableOOSLog(); g_Game->GetSimulation2()->EnableOOSLog();
// Need some stuff for terrain movement costs:
// (TODO: this ought to be independent of any graphics code)
new CTerrainTextureManager;
g_TexMan.LoadTerrainTextures();
// Initialise h_mgr so it doesn't crash when emitting sounds // Initialise h_mgr so it doesn't crash when emitting sounds
h_mgr_init(); h_mgr_init();
@ -329,9 +324,6 @@ void CReplayPlayer::Replay(const bool serializationtest, const int rejointesttur
// it's already destructed. // it's already destructed.
g_ScriptContext.reset(); g_ScriptContext.reset();
// Clean up
delete &g_TexMan;
delete &g_Profiler; delete &g_Profiler;
delete &g_ProfileViewer; delete &g_ProfileViewer;
SAFE_DELETE(g_ScriptStatsTable); SAFE_DELETE(g_ScriptStatsTable);

View File

@ -316,6 +316,8 @@ CRenderer::CRenderer()
CRenderer::~CRenderer() CRenderer::~CRenderer()
{ {
delete &g_TexMan;
// We no longer UnloadWaterTextures here - // We no longer UnloadWaterTextures here -
// that is the responsibility of the module that asked for // that is the responsibility of the module that asked for
// them to be loaded (i.e. CGameView). // them to be loaded (i.e. CGameView).

View File

@ -1163,13 +1163,8 @@ bool CCmpUnitMotion::PerformMove(fixed dt, const fixed& turnRate, WaypointPath&
basicSpeed = std::max(std::min(m_TemplateWalkSpeed, floorSpeed), basicSpeed); basicSpeed = std::max(std::min(m_TemplateWalkSpeed, floorSpeed), basicSpeed);
} }
// Find the speed factor of the underlying terrain. // TODO: would be nice to support terrain-dependent speed again.
// (We only care about the tile we start on - it doesn't matter if we're moving fixed maxSpeed = basicSpeed;
// partially onto a much slower/faster tile).
// TODO: Terrain-dependent speeds are not currently supported.
fixed terrainSpeed = fixed::FromInt(1);
fixed maxSpeed = basicSpeed.Multiply(terrainSpeed);
fixed timeLeft = dt; fixed timeLeft = dt;
fixed zero = fixed::Zero(); fixed zero = fixed::Zero();

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -45,16 +45,10 @@ public:
TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir() / "_testcache" / "", 0, VFS_MAX_PRIORITY)); TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir() / "_testcache" / "", 0, VFS_MAX_PRIORITY));
CXeromyces::Startup(); CXeromyces::Startup();
// Need some stuff for terrain movement costs:
// (TODO: this ought to be independent of any graphics code)
new CTerrainTextureManager;
g_TexMan.LoadTerrainTextures();
} }
void tearDown() void tearDown()
{ {
delete &g_TexMan;
CXeromyces::Terminate(); CXeromyces::Terminate();
g_VFS.reset(); g_VFS.reset();
DeleteDirectory(DataDir()/"_testcache"); DeleteDirectory(DataDir()/"_testcache");

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -192,8 +192,7 @@ namespace Pathfinding
/* /*
* For efficient pathfinding we want to try hard to minimise the per-tile search cost, * For efficient pathfinding we want to try hard to minimise the per-tile search cost,
* so we precompute the tile passability flags and movement costs for the various different * so we precompute the tile passability flags for the various different types of unit.
* types of unit.
* We also want to minimise memory usage (there can easily be 100K tiles so we don't want * We also want to minimise memory usage (there can easily be 100K tiles so we don't want
* to store many bytes for each). * to store many bytes for each).
* *

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games. /* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -885,11 +885,6 @@ public:
TS_ASSERT_OK(g_VFS->Mount(L"", DataDir() / "mods" / "public" / "", VFS_MOUNT_MUST_EXIST)); TS_ASSERT_OK(g_VFS->Mount(L"", DataDir() / "mods" / "public" / "", VFS_MOUNT_MUST_EXIST));
TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir() / "_testcache" / "", 0, VFS_MAX_PRIORITY)); TS_ASSERT_OK(g_VFS->Mount(L"cache", DataDir() / "_testcache" / "", 0, VFS_MAX_PRIORITY));
// Need some stuff for terrain movement costs:
// (TODO: this ought to be independent of any graphics code)
new CTerrainTextureManager;
g_TexMan.LoadTerrainTextures();
CTerrain terrain; CTerrain terrain;
CSimulation2 sim2(NULL, g_ScriptContext, &terrain); CSimulation2 sim2(NULL, g_ScriptContext, &terrain);
@ -938,7 +933,6 @@ public:
debug_printf("# time = %f (%f/%d)\n", t/reps, t, (int)reps); debug_printf("# time = %f (%f/%d)\n", t/reps, t, (int)reps);
// Shut down the world // Shut down the world
delete &g_TexMan;
g_VFS.reset(); g_VFS.reset();
DeleteDirectory(DataDir()/"_testcache"); DeleteDirectory(DataDir()/"_testcache");
CXeromyces::Terminate(); CXeromyces::Terminate();