Ejemplo n.º 1
0
float CGround::TrajectoryGroundCol(float3 from, const float3& flatdir, float length, float linear, float quadratic) const
{
	float3 dir(flatdir.x, linear, flatdir.z);

	// limit the checking to the `in map part` of the line
	std::pair<float,float> near_far = GetMapBoundaryIntersectionPoints(from, dir*length);

	// outside of map
	if (near_far.second < 0.0f)
		return -1.0;

	const float near = length * std::max(0.0f, near_far.first);
	const float far  = length * std::min(1.0f, near_far.second);

	for (float l = near; l < far; l += SQUARE_SIZE) {
		float3 pos(from + dir*l);
		pos.y += quadratic * l * l;

		if (GetApproximateHeight(pos.x, pos.z) > pos.y) {
			return l;
		}
	}

	return -1.0f;
}
Ejemplo n.º 2
0
float CGround::TrajectoryGroundCol(float3 from, float3 flatdir, float length, float linear, float quadratic)
{
    from.CheckInBounds();

    float3 dir(flatdir.x, linear, flatdir.z);

    for (float l = 0.0f; l < length; l += 8.0f) {
        float3 pos(from + dir * l);
        pos.y += quadratic * l * l;

        if (GetApproximateHeight(pos.x, pos.z) > pos.y) {
            return l;
        }
    }
    return -1;
}
Ejemplo n.º 3
0
float CGround::TrajectoryGroundCol(float3 from, float3 flatdir, float length, float linear, float quadratic)
{
	from.CheckInBounds();

	float3 dir(flatdir.x,linear,flatdir.z);
//	float3 oldpos=from;
	for(float l=0;l<length;l+=8){
		float3 pos(from+dir*l);
		pos.y+=quadratic*l*l;
		if(GetApproximateHeight(pos.x,pos.z)>pos.y){
			return l;
		}
//		geometricObjects->AddLine(pos,oldpos,3,0,16);
//		oldpos=pos;
	}	
	return -1;
}