18 #include "precompiled.h"
49 "<a:help>Approximation of the entity's shape, for collision detection and outline rendering. "
50 "Shapes are flat horizontal squares or circles, extended vertically to a given height.</a:help>"
52 "<Square width='3.0' height='3.0'/>"
53 "<Height>0.0</Height>"
56 "<Circle radius='0.5'/>"
57 "<Height>0.0</Height>"
60 "<element name='Square' a:help='Set the footprint to a square of the given size'>"
61 "<attribute name='width' a:help='Size of the footprint along the left/right direction (in metres)'>"
62 "<ref name='positiveDecimal'/>"
64 "<attribute name='depth' a:help='Size of the footprint along the front/back direction (in metres)'>"
65 "<ref name='positiveDecimal'/>"
68 "<element name='Circle' a:help='Set the footprint to a circle of the given size'>"
69 "<attribute name='radius' a:help='Radius of the footprint (in metres)'>"
70 "<ref name='positiveDecimal'/>"
74 "<element name='Height' a:help='Vertical extent of the footprint (in metres)'>"
75 "<ref name='nonNegativeDecimal'/>"
134 if (!cmpPosition || !cmpPosition->
IsInWorld())
138 if (!cmpObstructionManager)
145 if (cmpSpawnedObstruction)
166 const i32 maxSpawningDistance = 4;
171 for (
i32 dist = 0; dist <= maxSpawningDistance; ++dist)
178 const i32 numPoints = 31 + 2*dist;
179 for (
i32 i = 0; i < (numPoints+1)/2; i = (i > 0 ? -i : 1-i))
200 for (
i32 dist = 0; dist <= maxSpawningDistance; ++dist)
205 for (
i32 edge = 0; edge < 4; ++edge)
208 const i32 numPoints = 9 + 2*dist;
237 dir = dir.
Multiply((sx + clearance*2) / (
int)(numPoints-1));
239 for (
i32 i = 0; i < (numPoints+1)/2; i = (i > 0 ? -i : 1-i))
An entity initialisation parameter node.
A simple fixed-point number class.
#define REGISTER_COMPONENT_TYPE(cname)
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
bool IsOk() const
Returns true if this is a valid CParamNode, false if it represents a non-existent node...
Serialization interface; see serialization overview.
virtual CFixedVector3D GetRotation()=0
Returns the current rotation (relative to the upwards axis), as Euler angles with X=pitch...
virtual bool IsInWorld()=0
Returns true if the entity currently exists at a defined position in the world.
CEntityHandle GetEntityHandle() const
fixed ToFixed() const
Parses the content of this node as a fixed-point number.
const CParamNode & GetChild(const char *name) const
Returns the (unique) child node with the given name, or a node with IsOk() == false if there is none...
CFixedVector2D Perpendicular()
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter &filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass)=0
Check whether a unit placed here is valid and doesn't hit any obstructions or impassable terrain...
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
virtual CFixedVector2D GetPosition2D()=0
Returns the current x,z position (no interpolation).
#define DEFAULT_COMPONENT_ALLOCATOR(cname)
const CSimContext & GetSimContext() const
A simplified syntax for accessing entity components.
CEntityHandle GetSystemEntity() const
static CFixed FromInt(int n)
virtual ICmpPathfinder::pass_class_t GetPassabilityClass()=0
Get the unit's passability class.
virtual entity_pos_t GetUnitRadius()=0
CFixedVector2D Multiply(fixed n) const
Multiply by a CFixed.
Obstruction test filter that will test only against shapes that do not have the specified tag set...
JSBool error(JSContext *cx, uintN argc, jsval *vp)
void sincos_approx(CFixed_15_16 a, CFixed_15_16 &sin_out, CFixed_15_16 &cos_out)
Compute sin(a) and cos(a).
u32 entity_id_t
Entity ID type.
virtual ICmpObstructionManager::tag_t GetObstruction()=0
Deserialization interface; see serialization overview.
External identifiers for shapes.