2004-06-01 19:34:12 +02:00
|
|
|
#include "precompiled.h"
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2005-06-28 06:06:25 +02:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
#include <set>
|
|
|
|
#include <algorithm>
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/Pyrogenesis.h"
|
2005-08-12 19:06:53 +02:00
|
|
|
#include "lib/res/graphics/ogl_tex.h"
|
2006-02-13 15:18:20 +01:00
|
|
|
#include "graphics/LightEnv.h"
|
2004-05-30 02:46:58 +02:00
|
|
|
#include "Renderer.h"
|
2006-01-07 02:04:26 +01:00
|
|
|
#include "renderer/PatchRData.h"
|
2004-05-30 02:46:58 +02:00
|
|
|
#include "AlphaMapCalculator.h"
|
2004-07-15 21:29:56 +02:00
|
|
|
#include "ps/CLogger.h"
|
2005-11-06 05:16:19 +01:00
|
|
|
#include "ps/Profile.h"
|
2007-01-13 23:44:42 +01:00
|
|
|
#include "ps/Game.h"
|
|
|
|
#include "ps/World.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "maths/MathUtil.h"
|
|
|
|
#include "simulation/LOSManager.h"
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "graphics/Patch.h"
|
|
|
|
#include "graphics/Terrain.h"
|
2004-05-30 02:46:58 +02:00
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
const ssize_t BlendOffsets[8][2] = {
|
2004-05-30 02:46:58 +02:00
|
|
|
{ 0, -1 },
|
|
|
|
{ -1, -1 },
|
|
|
|
{ -1, 0 },
|
|
|
|
{ -1, 1 },
|
|
|
|
{ 0, 1 },
|
|
|
|
{ 1, 1 },
|
|
|
|
{ 1, 0 },
|
|
|
|
{ 1, -1 }
|
|
|
|
};
|
|
|
|
|
2004-10-06 20:44:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// CPatchRData constructor
|
2006-02-13 15:18:20 +01:00
|
|
|
CPatchRData::CPatchRData(CPatch* patch) : m_Patch(patch), m_VBBase(0), m_VBBlends(0), m_Vertices(0)
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
2005-06-28 06:06:25 +02:00
|
|
|
debug_assert(patch);
|
2004-05-30 02:46:58 +02:00
|
|
|
Build();
|
|
|
|
}
|
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// CPatchRData destructor
|
2006-02-13 15:18:20 +01:00
|
|
|
CPatchRData::~CPatchRData()
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
2004-06-11 00:24:03 +02:00
|
|
|
// delete copy of vertex data
|
|
|
|
delete[] m_Vertices;
|
2004-06-07 21:53:58 +02:00
|
|
|
// release vertex buffer chunks
|
2004-06-11 00:24:03 +02:00
|
|
|
if (m_VBBase) g_VBMan.Release(m_VBBase);
|
|
|
|
if (m_VBBlends) g_VBMan.Release(m_VBBlends);
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
static Handle GetTerrainTileTexture(CTerrain* terrain,ssize_t gx,ssize_t gz)
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
|
|
|
CMiniPatch* mp=terrain->GetTile(gx,gz);
|
|
|
|
return mp ? mp->Tex1 : 0;
|
|
|
|
}
|
|
|
|
|
2006-03-21 21:55:45 +01:00
|
|
|
const float uvFactor = 0.125f / sqrt(2.f);
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
static void CalculateUV(float uv[2], ssize_t x, ssize_t z)
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
2006-03-21 21:55:45 +01:00
|
|
|
// The UV axes are offset 45 degrees from XZ
|
|
|
|
uv[0] = ( x-z)*uvFactor;
|
|
|
|
uv[1] = (-x-z)*uvFactor;
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct STmpSplat {
|
|
|
|
Handle m_Texture;
|
|
|
|
u16 m_Indices[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
void CPatchRData::BuildBlends()
|
|
|
|
{
|
|
|
|
m_BlendIndices.clear();
|
|
|
|
m_BlendSplats.clear();
|
|
|
|
m_BlendVertices.clear();
|
2005-11-06 06:05:07 +01:00
|
|
|
m_BlendVertexIndices.clear();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
CTerrain* terrain=m_Patch->m_Parent;
|
|
|
|
|
|
|
|
// temporary list of splats
|
|
|
|
std::vector<STmpSplat> splats;
|
|
|
|
// set of textures used for splats
|
|
|
|
std::set<Handle> splatTextures;
|
|
|
|
|
|
|
|
// for each tile in patch ..
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t j=0;j<PATCH_SIZE;j++) {
|
|
|
|
for (ssize_t i=0;i<PATCH_SIZE;i++) {
|
|
|
|
ssize_t gx,gz;
|
2004-05-30 02:46:58 +02:00
|
|
|
CMiniPatch* mp=&m_Patch->m_MiniPatches[j][i];
|
|
|
|
mp->GetTileIndex(gx,gz);
|
|
|
|
|
|
|
|
// build list of textures of higher priority than current tile that are used by neighbouring tiles
|
|
|
|
std::vector<STex> neighbourTextures;
|
2006-02-13 15:18:20 +01:00
|
|
|
for (int m=-1;m<=1;m++) {
|
2004-05-30 02:46:58 +02:00
|
|
|
for (int k=-1;k<=1;k++) {
|
|
|
|
CMiniPatch* nmp=terrain->GetTile(gx+k,gz+m);
|
2005-11-06 06:05:07 +01:00
|
|
|
if (nmp && nmp->Tex1 != mp->Tex1) {
|
2004-05-30 02:46:58 +02:00
|
|
|
if (nmp->Tex1Priority>mp->Tex1Priority || (nmp->Tex1Priority==mp->Tex1Priority && nmp->Tex1>mp->Tex1)) {
|
|
|
|
STex tex;
|
|
|
|
tex.m_Handle=nmp->Tex1;
|
|
|
|
tex.m_Priority=nmp->Tex1Priority;
|
|
|
|
if (std::find(neighbourTextures.begin(),neighbourTextures.end(),tex)==neighbourTextures.end()) {
|
|
|
|
neighbourTextures.push_back(tex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (neighbourTextures.size()>0) {
|
|
|
|
// sort textures from lowest to highest priority
|
|
|
|
std::sort(neighbourTextures.begin(),neighbourTextures.end());
|
|
|
|
|
|
|
|
// for each of the neighbouring textures ..
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
size_t count=neighbourTextures.size();
|
|
|
|
for (size_t k=0;k<count;++k) {
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2006-02-13 15:18:20 +01:00
|
|
|
// now build the grid of blends dependent on whether the tile adjacent to the current tile
|
2004-05-30 02:46:58 +02:00
|
|
|
// uses the current neighbour texture
|
|
|
|
BlendShape8 shape;
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (size_t m=0;m<8;m++) {
|
|
|
|
ssize_t ox=gx+BlendOffsets[m][1];
|
|
|
|
ssize_t oz=gz+BlendOffsets[m][0];
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// get texture on adjacent tile
|
|
|
|
Handle atex=GetTerrainTileTexture(terrain,ox,oz);
|
|
|
|
// fill 0/1 into shape array
|
|
|
|
shape[m]=(atex==neighbourTextures[k].m_Handle) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate the required alphamap and the required rotation of the alphamap from blendshape
|
|
|
|
unsigned int alphamapflags;
|
|
|
|
int alphamap=CAlphaMapCalculator::Calculate(shape,alphamapflags);
|
|
|
|
|
|
|
|
// now actually render the blend tile (if we need one)
|
|
|
|
if (alphamap!=-1) {
|
|
|
|
float u0=g_Renderer.m_AlphaMapCoords[alphamap].u0;
|
|
|
|
float u1=g_Renderer.m_AlphaMapCoords[alphamap].u1;
|
|
|
|
float v0=g_Renderer.m_AlphaMapCoords[alphamap].v0;
|
|
|
|
float v1=g_Renderer.m_AlphaMapCoords[alphamap].v1;
|
|
|
|
if (alphamapflags & BLENDMAP_FLIPU) {
|
|
|
|
// flip u
|
|
|
|
float t=u0;
|
|
|
|
u0=u1;
|
|
|
|
u1=t;
|
2006-02-13 15:18:20 +01:00
|
|
|
}
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
if (alphamapflags & BLENDMAP_FLIPV) {
|
|
|
|
// flip v
|
|
|
|
float t=v0;
|
|
|
|
v0=v1;
|
|
|
|
v1=t;
|
2006-02-13 15:18:20 +01:00
|
|
|
}
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
int base=0;
|
|
|
|
if (alphamapflags & BLENDMAP_ROTATE90) {
|
2006-02-13 15:18:20 +01:00
|
|
|
// rotate 1
|
2004-05-30 02:46:58 +02:00
|
|
|
base=1;
|
|
|
|
} else if (alphamapflags & BLENDMAP_ROTATE180) {
|
|
|
|
// rotate 2
|
|
|
|
base=2;
|
|
|
|
} else if (alphamapflags & BLENDMAP_ROTATE270) {
|
|
|
|
// rotate 3
|
|
|
|
base=3;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBlendVertex vtx[4];
|
|
|
|
vtx[(base+0)%4].m_AlphaUVs[0]=u0;
|
|
|
|
vtx[(base+0)%4].m_AlphaUVs[1]=v0;
|
|
|
|
vtx[(base+1)%4].m_AlphaUVs[0]=u1;
|
|
|
|
vtx[(base+1)%4].m_AlphaUVs[1]=v0;
|
|
|
|
vtx[(base+2)%4].m_AlphaUVs[0]=u1;
|
|
|
|
vtx[(base+2)%4].m_AlphaUVs[1]=v1;
|
|
|
|
vtx[(base+3)%4].m_AlphaUVs[0]=u0;
|
|
|
|
vtx[(base+3)%4].m_AlphaUVs[1]=v1;
|
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t vsize=PATCH_SIZE+1;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
SBlendVertex dst;
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
const size_t vindex=m_BlendVertices.size();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
const SBaseVertex& vtx0=m_Vertices[(j*vsize)+i];
|
2006-03-21 21:55:45 +01:00
|
|
|
CalculateUV(dst.m_UVs, gx, gz);
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_AlphaUVs[0]=vtx[0].m_AlphaUVs[0];
|
|
|
|
dst.m_AlphaUVs[1]=vtx[0].m_AlphaUVs[1];
|
2006-02-13 15:18:20 +01:00
|
|
|
dst.m_LOSColor=vtx0.m_LOSColor;
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_Position=vtx0.m_Position;
|
|
|
|
m_BlendVertices.push_back(dst);
|
2005-10-09 10:14:42 +02:00
|
|
|
m_BlendVertexIndices.push_back((j*vsize)+i);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
const SBaseVertex& vtx1=m_Vertices[(j*vsize)+i+1];
|
2006-03-21 21:55:45 +01:00
|
|
|
CalculateUV(dst.m_UVs, gx+1, gz);
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_AlphaUVs[0]=vtx[1].m_AlphaUVs[0];
|
|
|
|
dst.m_AlphaUVs[1]=vtx[1].m_AlphaUVs[1];
|
2006-02-13 15:18:20 +01:00
|
|
|
dst.m_LOSColor=vtx1.m_LOSColor;
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_Position=vtx1.m_Position;
|
|
|
|
m_BlendVertices.push_back(dst);
|
2005-10-09 10:14:42 +02:00
|
|
|
m_BlendVertexIndices.push_back((j*vsize)+i+1);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
const SBaseVertex& vtx2=m_Vertices[((j+1)*vsize)+i+1];
|
2006-03-21 21:55:45 +01:00
|
|
|
CalculateUV(dst.m_UVs, gx+1, gz+1);
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_AlphaUVs[0]=vtx[2].m_AlphaUVs[0];
|
|
|
|
dst.m_AlphaUVs[1]=vtx[2].m_AlphaUVs[1];
|
2006-02-13 15:18:20 +01:00
|
|
|
dst.m_LOSColor=vtx2.m_LOSColor;
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_Position=vtx2.m_Position;
|
|
|
|
m_BlendVertices.push_back(dst);
|
2005-10-09 10:14:42 +02:00
|
|
|
m_BlendVertexIndices.push_back(((j+1)*vsize)+i+1);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
const SBaseVertex& vtx3=m_Vertices[((j+1)*vsize)+i];
|
2006-03-21 21:55:45 +01:00
|
|
|
CalculateUV(dst.m_UVs, gx, gz+1);
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_AlphaUVs[0]=vtx[3].m_AlphaUVs[0];
|
|
|
|
dst.m_AlphaUVs[1]=vtx[3].m_AlphaUVs[1];
|
2006-02-13 15:18:20 +01:00
|
|
|
dst.m_LOSColor=vtx3.m_LOSColor;
|
2004-05-30 02:46:58 +02:00
|
|
|
dst.m_Position=vtx3.m_Position;
|
|
|
|
m_BlendVertices.push_back(dst);
|
2005-10-09 10:14:42 +02:00
|
|
|
m_BlendVertexIndices.push_back(((j+1)*vsize)+i);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// build a splat for this quad
|
|
|
|
STmpSplat splat;
|
|
|
|
splat.m_Texture=neighbourTextures[k].m_Handle;
|
2004-07-24 16:04:40 +02:00
|
|
|
splat.m_Indices[0]=(u16)(vindex);
|
|
|
|
splat.m_Indices[1]=(u16)(vindex+1);
|
|
|
|
splat.m_Indices[2]=(u16)(vindex+2);
|
|
|
|
splat.m_Indices[3]=(u16)(vindex+3);
|
2004-05-30 02:46:58 +02:00
|
|
|
splats.push_back(splat);
|
|
|
|
|
|
|
|
// add this texture to set of unique splat textures
|
|
|
|
splatTextures.insert(splat.m_Texture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-06-07 21:53:58 +02:00
|
|
|
// build vertex data
|
2004-06-11 00:24:03 +02:00
|
|
|
if (m_VBBlends) {
|
|
|
|
// release existing vertex buffer chunk
|
2004-06-07 21:53:58 +02:00
|
|
|
g_VBMan.Release(m_VBBlends);
|
2004-10-06 20:44:47 +02:00
|
|
|
m_VBBlends=0;
|
2004-06-11 00:24:03 +02:00
|
|
|
}
|
2005-12-18 03:04:24 +01:00
|
|
|
if (m_BlendVertices.size()) {
|
2005-11-06 05:16:19 +01:00
|
|
|
m_VBBlends=g_VBMan.Allocate(sizeof(SBlendVertex),m_BlendVertices.size(),true);
|
2004-10-06 20:44:47 +02:00
|
|
|
m_VBBlends->m_Owner->UpdateChunkVertices(m_VBBlends,&m_BlendVertices[0]);
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-10-06 20:44:47 +02:00
|
|
|
// now build outgoing splats
|
|
|
|
m_BlendSplats.resize(splatTextures.size());
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
size_t splatCount=0;
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2005-06-28 06:06:25 +02:00
|
|
|
debug_assert(m_VBBlends->m_Index < 65536);
|
2004-10-06 20:44:47 +02:00
|
|
|
unsigned short base = (unsigned short)m_VBBlends->m_Index;
|
|
|
|
std::set<Handle>::iterator iter=splatTextures.begin();
|
|
|
|
for (;iter!=splatTextures.end();++iter) {
|
|
|
|
Handle tex=*iter;
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-10-06 20:44:47 +02:00
|
|
|
SSplat& splat=m_BlendSplats[splatCount];
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
splat.m_IndexStart=m_BlendIndices.size();
|
2004-10-06 20:44:47 +02:00
|
|
|
splat.m_Texture=tex;
|
2006-02-13 15:18:20 +01:00
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (size_t k=0;k<splats.size();k++) {
|
2004-10-06 20:44:47 +02:00
|
|
|
if (splats[k].m_Texture==tex) {
|
|
|
|
m_BlendIndices.push_back(splats[k].m_Indices[0]+base);
|
|
|
|
m_BlendIndices.push_back(splats[k].m_Indices[1]+base);
|
|
|
|
m_BlendIndices.push_back(splats[k].m_Indices[2]+base);
|
|
|
|
m_BlendIndices.push_back(splats[k].m_Indices[3]+base);
|
|
|
|
splat.m_IndexCount+=4;
|
|
|
|
}
|
2004-06-11 00:24:03 +02:00
|
|
|
}
|
2004-10-06 20:44:47 +02:00
|
|
|
splatCount++;
|
2004-06-11 00:24:03 +02:00
|
|
|
}
|
|
|
|
}
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPatchRData::BuildIndices()
|
2004-06-11 00:24:03 +02:00
|
|
|
{
|
|
|
|
// must have allocated some vertices before trying to build corresponding indices
|
2005-06-28 06:06:25 +02:00
|
|
|
debug_assert(m_VBBase);
|
2004-06-07 21:53:58 +02:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// number of vertices in each direction in each patch
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t vsize=PATCH_SIZE+1;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// release existing indices and bins
|
|
|
|
m_Indices.clear();
|
2004-10-06 20:44:47 +02:00
|
|
|
m_ShadowMapIndices.clear();
|
2004-05-30 02:46:58 +02:00
|
|
|
m_Splats.clear();
|
|
|
|
|
|
|
|
// build grid of textures on this patch and boundaries of adjacent patches
|
|
|
|
std::vector<Handle> textures;
|
|
|
|
Handle texgrid[PATCH_SIZE][PATCH_SIZE];
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t j=0;j<PATCH_SIZE;j++) {
|
|
|
|
for (ssize_t i=0;i<PATCH_SIZE;i++) {
|
2004-05-30 02:46:58 +02:00
|
|
|
Handle h=m_Patch->m_MiniPatches[j][i].Tex1;
|
|
|
|
texgrid[j][i]=h;
|
|
|
|
if (std::find(textures.begin(),textures.end(),h)==textures.end()) {
|
|
|
|
textures.push_back(h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// now build base splats from interior textures
|
|
|
|
m_Splats.resize(textures.size());
|
2006-02-13 15:18:20 +01:00
|
|
|
// build indices for base splats
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
size_t base=m_VBBase->m_Index;
|
|
|
|
for (size_t i=0;i<m_Splats.size();i++) {
|
2004-05-30 02:46:58 +02:00
|
|
|
Handle h=textures[i];
|
|
|
|
|
|
|
|
SSplat& splat=m_Splats[i];
|
|
|
|
splat.m_Texture=h;
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
splat.m_IndexStart=m_Indices.size();
|
2006-02-13 15:18:20 +01:00
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t j=0;j<PATCH_SIZE;j++) {
|
|
|
|
for (ssize_t i=0;i<PATCH_SIZE;i++) {
|
2004-05-30 02:46:58 +02:00
|
|
|
if (texgrid[j][i]==h){
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
m_Indices.push_back(u16(((j+0)*vsize+(i+0))+base));
|
|
|
|
m_Indices.push_back(u16(((j+0)*vsize+(i+1))+base));
|
|
|
|
m_Indices.push_back(u16(((j+1)*vsize+(i+1))+base));
|
|
|
|
m_Indices.push_back(u16(((j+1)*vsize+(i+0))+base));
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
splat.m_IndexCount=m_Indices.size()-splat.m_IndexStart;
|
2004-06-11 00:24:03 +02:00
|
|
|
}
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
// build indices for the shadow map pass
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t j=0;j<PATCH_SIZE;j++) {
|
|
|
|
for (ssize_t i=0;i<PATCH_SIZE;i++) {
|
|
|
|
m_ShadowMapIndices.push_back(u16(((j+0)*vsize+(i+0))+base));
|
|
|
|
m_ShadowMapIndices.push_back(u16(((j+0)*vsize+(i+1))+base));
|
|
|
|
m_ShadowMapIndices.push_back(u16(((j+1)*vsize+(i+1))+base));
|
|
|
|
m_ShadowMapIndices.push_back(u16(((j+1)*vsize+(i+0))+base));
|
2004-06-11 00:24:03 +02:00
|
|
|
}
|
|
|
|
}
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPatchRData::BuildVertices()
|
|
|
|
{
|
2005-10-09 10:14:42 +02:00
|
|
|
// create both vertices and lighting colors
|
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
CVector3D normal;
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// number of vertices in each direction in each patch
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t vsize=PATCH_SIZE+1;
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
if (!m_Vertices) {
|
|
|
|
m_Vertices=new SBaseVertex[vsize*vsize];
|
|
|
|
}
|
|
|
|
SBaseVertex* vertices=m_Vertices;
|
2006-02-13 15:18:20 +01:00
|
|
|
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// get index of this patch
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t px=m_Patch->m_X;
|
|
|
|
ssize_t pz=m_Patch->m_Z;
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
CTerrain* terrain=m_Patch->m_Parent;
|
2006-02-13 15:18:20 +01:00
|
|
|
const CLightEnv& lightEnv = g_Renderer.GetLightEnv();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
// build vertices
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t j=0;j<vsize;j++) {
|
|
|
|
for (ssize_t i=0;i<vsize;i++) {
|
|
|
|
ssize_t ix=px*PATCH_SIZE+i;
|
|
|
|
ssize_t iz=pz*PATCH_SIZE+j;
|
|
|
|
ssize_t v=(j*vsize)+i;
|
2004-06-07 21:53:58 +02:00
|
|
|
|
2005-10-09 10:14:42 +02:00
|
|
|
// calculate vertex data
|
2006-02-13 15:18:20 +01:00
|
|
|
terrain->CalcPosition(ix,iz,vertices[v].m_Position);
|
|
|
|
*(uint32_t*)&vertices[v].m_LOSColor = 0; // will be set to the proper value in Update()
|
2006-03-21 21:55:45 +01:00
|
|
|
CalculateUV(vertices[v].m_UVs, ix, iz);
|
2006-02-13 15:18:20 +01:00
|
|
|
|
|
|
|
// Calculate diffuse lighting for this vertex
|
|
|
|
// Ambient is added by the lighting pass (since ambient is the same
|
|
|
|
// for all vertices, it need not be stored in the vertex structure)
|
2005-10-09 10:14:42 +02:00
|
|
|
terrain->CalcNormal(ix,iz,normal);
|
2006-02-13 15:18:20 +01:00
|
|
|
|
|
|
|
RGBColor diffuse;
|
|
|
|
lightEnv.EvaluateDirect(normal, diffuse);
|
2008-06-30 21:08:29 +02:00
|
|
|
vertices[v].m_DiffuseColor = ConvertRGBColorTo4ub(diffuse);
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
}
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2005-10-09 10:14:42 +02:00
|
|
|
// upload to vertex buffer
|
2004-06-11 00:24:03 +02:00
|
|
|
if (!m_VBBase) {
|
2005-11-06 05:16:19 +01:00
|
|
|
m_VBBase=g_VBMan.Allocate(sizeof(SBaseVertex),vsize*vsize,true);
|
2006-01-07 02:04:26 +01:00
|
|
|
}
|
2004-06-07 21:53:58 +02:00
|
|
|
m_VBBase->m_Owner->UpdateChunkVertices(m_VBBase,m_Vertices);
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPatchRData::Build()
|
|
|
|
{
|
|
|
|
BuildVertices();
|
|
|
|
BuildIndices();
|
|
|
|
BuildBlends();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatchRData::Update()
|
|
|
|
{
|
|
|
|
if (m_UpdateFlags!=0) {
|
|
|
|
// TODO,RC 11/04/04 - need to only rebuild necessary bits of renderdata rather
|
|
|
|
// than everything; it's complicated slightly because the blends are dependent
|
|
|
|
// on both vertex and index data
|
2005-10-09 10:14:42 +02:00
|
|
|
BuildVertices();
|
2004-05-30 02:46:58 +02:00
|
|
|
BuildIndices();
|
2005-10-09 10:14:42 +02:00
|
|
|
BuildBlends();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
m_UpdateFlags=0;
|
|
|
|
}
|
2005-10-09 06:40:18 +02:00
|
|
|
|
2005-10-09 10:14:42 +02:00
|
|
|
// Update vertex colors, which are affected by LOS
|
2006-02-13 15:18:20 +01:00
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t px=m_Patch->m_X;
|
|
|
|
ssize_t pz=m_Patch->m_Z;
|
2005-10-09 10:14:42 +02:00
|
|
|
|
|
|
|
CTerrain* terrain=m_Patch->m_Parent;
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t mapSize=terrain->GetVerticesPerSide();
|
|
|
|
ssize_t vsize=PATCH_SIZE+1;
|
2006-09-26 03:44:20 +02:00
|
|
|
SColor4ub baseColour = terrain->GetBaseColour();
|
2005-10-09 10:14:42 +02:00
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
if (g_Game)
|
|
|
|
{
|
|
|
|
CLOSManager* losMgr = g_Game->GetWorld()->GetLOSManager();
|
2005-10-09 10:14:42 +02:00
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
// this is very similar to BuildVertices(), but just for color
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t j=0;j<vsize;j++) {
|
|
|
|
for (ssize_t i=0;i<vsize;i++) {
|
|
|
|
ssize_t ix=px*PATCH_SIZE+i;
|
|
|
|
ssize_t iz=pz*PATCH_SIZE+j;
|
|
|
|
ssize_t v=(j*vsize)+i;
|
|
|
|
|
|
|
|
const ssize_t DX[] = {1,1,0,0};
|
|
|
|
const ssize_t DZ[] = {0,1,1,0};
|
2006-09-26 03:44:20 +02:00
|
|
|
SColor4ub losMod = baseColour;
|
2005-10-09 10:14:42 +02:00
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for(size_t k=0; k<4; k++)
|
2005-10-09 10:14:42 +02:00
|
|
|
{
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t tx = ix - DX[k];
|
|
|
|
ssize_t tz = iz - DZ[k];
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
|
|
|
|
if(tx >= 0 && tz >= 0 && tx <= mapSize-2 && tz <= mapSize-2)
|
|
|
|
{
|
|
|
|
ELOSStatus s = losMgr->GetStatus(tx, tz, g_Game->GetLocalPlayer());
|
|
|
|
if(s==LOS_EXPLORED && losMod.R > 178)
|
|
|
|
losMod = SColor4ub(178, 178, 178, 255);
|
|
|
|
else if(s==LOS_UNEXPLORED && losMod.R > 0)
|
|
|
|
losMod = SColor4ub(0, 0, 0, 255);
|
|
|
|
}
|
2005-10-09 10:14:42 +02:00
|
|
|
}
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
m_Vertices[v].m_LOSColor = losMod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t j = 0; j < vsize; ++j)
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
{
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t i = 0; i < vsize; ++i)
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
{
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
ssize_t v = (j*vsize)+i;
|
2006-09-26 03:44:20 +02:00
|
|
|
m_Vertices[v].m_LOSColor = baseColour;
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
}
|
2005-10-09 10:14:42 +02:00
|
|
|
}
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
|
2005-10-09 10:14:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// upload base vertices into their vertex buffer
|
|
|
|
m_VBBase->m_Owner->UpdateChunkVertices(m_VBBase,m_Vertices);
|
|
|
|
|
|
|
|
// update blend colors by copying them from vertex colors
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for(size_t i=0; i<m_BlendVertices.size(); i++)
|
2005-10-09 10:14:42 +02:00
|
|
|
{
|
2006-02-13 15:18:20 +01:00
|
|
|
m_BlendVertices[i].m_LOSColor = m_Vertices[m_BlendVertexIndices[i]].m_LOSColor;
|
2005-10-09 10:14:42 +02:00
|
|
|
}
|
2005-11-06 05:16:19 +01:00
|
|
|
|
2005-10-09 10:14:42 +02:00
|
|
|
// upload blend vertices into their vertex buffer too
|
|
|
|
if(m_BlendVertices.size())
|
|
|
|
{
|
|
|
|
m_VBBlends->m_Owner->UpdateChunkVertices(m_VBBlends,&m_BlendVertices[0]);
|
|
|
|
}
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
|
2006-02-13 15:18:20 +01:00
|
|
|
void CPatchRData::RenderBase(bool losColor)
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
2005-06-28 06:06:25 +02:00
|
|
|
debug_assert(m_UpdateFlags==0);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2006-01-29 19:23:47 +01:00
|
|
|
SBaseVertex *base=(SBaseVertex *)m_VBBase->m_Owner->Bind();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// setup data pointers
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
GLsizei stride=sizeof(SBaseVertex);
|
2006-01-29 19:23:47 +01:00
|
|
|
glVertexPointer(3,GL_FLOAT,stride,&base->m_Position[0]);
|
2006-02-13 15:18:20 +01:00
|
|
|
glColorPointer(4,GL_UNSIGNED_BYTE,stride,losColor ? &base->m_LOSColor : &base->m_DiffuseColor);
|
2006-01-29 19:23:47 +01:00
|
|
|
glTexCoordPointer(2,GL_FLOAT,stride,&base->m_UVs[0]);
|
2006-02-13 15:18:20 +01:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// render each splat
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (size_t i=0;i<m_Splats.size();i++) {
|
2004-05-30 02:46:58 +02:00
|
|
|
SSplat& splat=m_Splats[i];
|
2005-09-02 04:58:40 +02:00
|
|
|
ogl_tex_bind(splat.m_Texture);
|
2006-09-23 18:04:54 +02:00
|
|
|
|
|
|
|
if (!g_Renderer.m_SkipSubmit) {
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
glDrawElements(GL_QUADS, (GLsizei)splat.m_IndexCount,
|
2006-09-23 18:04:54 +02:00
|
|
|
GL_UNSIGNED_SHORT, &m_Indices[splat.m_IndexStart]);
|
|
|
|
}
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// bump stats
|
|
|
|
g_Renderer.m_Stats.m_DrawCalls++;
|
|
|
|
g_Renderer.m_Stats.m_TerrainTris+=splat.m_IndexCount/2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
void CPatchRData::RenderStreams(int streamflags, bool losColor)
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
2005-06-28 06:06:25 +02:00
|
|
|
debug_assert(m_UpdateFlags==0);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2006-01-29 19:23:47 +01:00
|
|
|
SBaseVertex* base=(SBaseVertex *)m_VBBase->m_Owner->Bind();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// setup data pointers
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
GLsizei stride=sizeof(SBaseVertex);
|
2006-01-29 19:23:47 +01:00
|
|
|
glVertexPointer(3, GL_FLOAT, stride, &base->m_Position);
|
2004-10-06 20:44:47 +02:00
|
|
|
if (streamflags & STREAM_UV0) {
|
2006-01-29 19:23:47 +01:00
|
|
|
glTexCoordPointer(2, GL_FLOAT, stride, &base->m_UVs);
|
2004-10-06 20:44:47 +02:00
|
|
|
} else if (streamflags & STREAM_POSTOUV0) {
|
2006-01-29 19:23:47 +01:00
|
|
|
glTexCoordPointer(3, GL_FLOAT, stride, &base->m_Position);
|
2004-10-06 20:44:47 +02:00
|
|
|
}
|
2006-02-13 15:18:20 +01:00
|
|
|
if (streamflags & STREAM_COLOR)
|
|
|
|
{
|
|
|
|
glColorPointer(4,GL_UNSIGNED_BYTE,stride,losColor ? &base->m_LOSColor : &base->m_DiffuseColor);
|
|
|
|
}
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// render all base splats at once
|
2006-09-23 18:04:54 +02:00
|
|
|
if (!g_Renderer.m_SkipSubmit) {
|
|
|
|
glDrawElements(GL_QUADS,(GLsizei)m_Indices.size(),GL_UNSIGNED_SHORT,&m_Indices[0]);
|
|
|
|
}
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// bump stats
|
|
|
|
g_Renderer.m_Stats.m_DrawCalls++;
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
g_Renderer.m_Stats.m_TerrainTris+=m_Indices.size()/2;
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPatchRData::RenderBlends()
|
|
|
|
{
|
2005-06-28 06:06:25 +02:00
|
|
|
debug_assert(m_UpdateFlags==0);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
if (m_BlendVertices.size()==0) return;
|
|
|
|
|
2004-06-11 00:24:03 +02:00
|
|
|
u8* base=m_VBBlends->m_Owner->Bind();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// setup data pointers
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
GLsizei stride=sizeof(SBlendVertex);
|
2006-11-07 14:28:03 +01:00
|
|
|
// ((GCC warns about offsetof: SBlendVertex contains a CVector3D which has
|
|
|
|
// a constructor, and so is not a POD type, and so offsetof is theoretically
|
|
|
|
// invalid - see http://gcc.gnu.org/ml/gcc/2003-11/msg00281.html - but it
|
|
|
|
// doesn't seem to be worth changing this code since it works anyway.))
|
2004-05-30 02:46:58 +02:00
|
|
|
glVertexPointer(3,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_Position));
|
2006-02-13 15:18:20 +01:00
|
|
|
glColorPointer(4,GL_UNSIGNED_BYTE,stride,base+offsetof(SBlendVertex,m_LOSColor));
|
|
|
|
|
2005-10-30 02:18:15 +01:00
|
|
|
pglClientActiveTextureARB(GL_TEXTURE0);
|
2004-05-30 02:46:58 +02:00
|
|
|
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_UVs[0]));
|
|
|
|
|
2005-10-30 02:18:15 +01:00
|
|
|
pglClientActiveTextureARB(GL_TEXTURE1);
|
2004-05-30 02:46:58 +02:00
|
|
|
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_AlphaUVs[0]));
|
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (size_t i=0;i<m_BlendSplats.size();i++) {
|
2004-05-30 02:46:58 +02:00
|
|
|
SSplat& splat=m_BlendSplats[i];
|
2005-09-02 04:58:40 +02:00
|
|
|
ogl_tex_bind(splat.m_Texture);
|
2006-09-23 18:04:54 +02:00
|
|
|
|
|
|
|
if (!g_Renderer.m_SkipSubmit) {
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
glDrawElements(GL_QUADS, (GLsizei)splat.m_IndexCount,
|
2006-09-23 18:04:54 +02:00
|
|
|
GL_UNSIGNED_SHORT, &m_BlendIndices[splat.m_IndexStart]);
|
|
|
|
}
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// bump stats
|
|
|
|
g_Renderer.m_Stats.m_DrawCalls++;
|
|
|
|
g_Renderer.m_Stats.m_BlendSplats++;
|
|
|
|
g_Renderer.m_Stats.m_TerrainTris+=splat.m_IndexCount/2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-06 20:44:47 +02:00
|
|
|
void CPatchRData::RenderOutline()
|
|
|
|
{
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
size_t vsize=PATCH_SIZE+1;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2004-10-06 20:44:47 +02:00
|
|
|
glBegin(GL_LINES);
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t i=0;i<PATCH_SIZE;i++) {
|
2004-10-06 20:44:47 +02:00
|
|
|
glVertex3fv(&m_Vertices[i].m_Position.X);
|
|
|
|
glVertex3fv(&m_Vertices[i+1].m_Position.X);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
glBegin(GL_LINES);
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t i=0;i<PATCH_SIZE;i++) {
|
2004-10-06 20:44:47 +02:00
|
|
|
glVertex3fv(&m_Vertices[PATCH_SIZE+(i*(PATCH_SIZE+1))].m_Position.X);
|
|
|
|
glVertex3fv(&m_Vertices[PATCH_SIZE+((i+1)*(PATCH_SIZE+1))].m_Position.X);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
glBegin(GL_LINES);
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t i=1;i<PATCH_SIZE;i++) {
|
2004-10-06 20:44:47 +02:00
|
|
|
glVertex3fv(&m_Vertices[(vsize*vsize)-i].m_Position.X);
|
|
|
|
glVertex3fv(&m_Vertices[(vsize*vsize)-(i+1)].m_Position.X);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
glBegin(GL_LINES);
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
for (ssize_t i=1;i<PATCH_SIZE;i++) {
|
2004-10-06 20:44:47 +02:00
|
|
|
glVertex3fv(&m_Vertices[(vsize*(vsize-1))-(i*vsize)].m_Position.X);
|
|
|
|
glVertex3fv(&m_Vertices[(vsize*(vsize-1))-((i+1)*vsize)].m_Position.X);
|
|
|
|
}
|
|
|
|
glEnd();
|
2004-05-30 02:46:58 +02:00
|
|
|
}
|