Changes terrain anchoring to use faster CalcExactNormal instead of CalcNormalFixed, refs #1988, #2039
This was SVN commit r13571.
This commit is contained in:
parent
1cca648b6d
commit
39c0498811
@ -568,8 +568,8 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO average normal (average all the tiles?) for big units or for buildings
|
||||
CVector3D normal = cmpTerrain->CalcNormal(m_X, m_Z);
|
||||
// TODO: average normal (average all the tiles?) for big units or for buildings?
|
||||
CVector3D normal = cmpTerrain->CalcExactNormal(m_X.ToFloat(), m_Z.ToFloat());
|
||||
|
||||
// rotate the normal so the positive x direction is in the direction of the unit
|
||||
CVector2D projected = CVector2D(normal.X, normal.Z);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -25,6 +25,7 @@
|
||||
#include "simulation2/MessageTypes.h"
|
||||
|
||||
#include "graphics/Terrain.h"
|
||||
#include "maths/Vector3D.h"
|
||||
|
||||
class CCmpTerrain : public ICmpTerrain
|
||||
{
|
||||
@ -72,6 +73,11 @@ public:
|
||||
return normal;
|
||||
}
|
||||
|
||||
virtual CVector3D CalcExactNormal(float x, float z)
|
||||
{
|
||||
return m_Terrain->CalcExactNormal(x, z);
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z)
|
||||
{
|
||||
// TODO: this can crash if the terrain heightmap isn't initialised yet
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -25,6 +25,7 @@
|
||||
#include "maths/FixedVector3D.h"
|
||||
|
||||
class CTerrain;
|
||||
class CVector3D;
|
||||
|
||||
class ICmpTerrain : public IComponent
|
||||
{
|
||||
@ -33,6 +34,8 @@ public:
|
||||
|
||||
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z) = 0;
|
||||
|
||||
virtual CVector3D CalcExactNormal(float x, float z) = 0;
|
||||
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z) = 0;
|
||||
|
||||
virtual float GetExactGroundLevel(float x, float z) = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -172,6 +172,11 @@ public:
|
||||
return CFixedVector3D(fixed::FromInt(0), fixed::FromInt(1), fixed::FromInt(0));
|
||||
}
|
||||
|
||||
virtual CVector3D CalcExactNormal(float UNUSED(x), float UNUSED(z))
|
||||
{
|
||||
return CVector3D(0.f, 1.f, 0.f);
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z))
|
||||
{
|
||||
return entity_pos_t::FromInt(50);
|
||||
|
Loading…
Reference in New Issue
Block a user