File: Ground.h

package info (click to toggle)
spring 0.81.2.1%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,496 kB
  • ctags: 37,096
  • sloc: cpp: 238,659; ansic: 13,784; java: 12,175; awk: 3,428; python: 1,159; xml: 738; perl: 405; sh: 297; makefile: 267; pascal: 228; objc: 192
file content (43 lines) | stat: -rw-r--r-- 1,266 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef GROUND_H
#define GROUND_H
// Ground.h: interface for the CGround class.
//
//////////////////////////////////////////////////////////////////////

#include "float3.h"
#include "Sim/Misc/GlobalConstants.h"
#include "Sim/Misc/GlobalSynced.h"

class CProjectile;


class CGround
{
public:
	CGround();
	virtual ~CGround();

	float GetApproximateHeight(float x,float y) const;
	float GetSlope(float x,float y) const;
	/// Returns the height at the specified position, cropped to a non-negative value
	float GetHeight(float x,float y) const;
	/// Returns the real height at the specified position, can be below 0
	float GetHeight2(float x,float y) const;
	float GetOrigHeight(float x,float y) const;
	float3& GetNormal(float x,float y) const;
	float3 GetSmoothNormal(float x,float y) const;
	float LineGroundCol(float3 from, float3 to) const;
	float TrajectoryGroundCol(float3 from, float3 flatdir, float length, float linear, float quadratic) const;

	inline int GetSquare(const float3& pos) {
		return std::max(0, std::min(gs->mapx - 1, (int(pos.x) / SQUARE_SIZE))) +
			std::max(0, std::min(gs->mapy - 1, (int(pos.z) / SQUARE_SIZE))) * gs->mapx;
	};
private:

	void CheckColSquare(CProjectile* p,int x,int y);
};

extern CGround* ground;

#endif /* GROUND_H */