mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
view range factor implementation
This commit is contained in:
41
usefull.h
41
usefull.h
@@ -9,17 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
//#define B1(t) (t*t*t)
|
||||
//#define B2(t) (3*t*t*(1-t))
|
||||
//#define B3(t) (3*t*(1-t)*(1-t))
|
||||
//#define B4(t) ((1-t)*(1-t)*(1-t))
|
||||
// Ra: to jest mocno nieoptymalne: 10+3*4=22 mnożenia, 6 odejmowań, 3*3=9 dodawań
|
||||
// Ra: po przeliczeniu współczynników mamy: 3*3=9 mnożeń i 3*3=9 dodawań
|
||||
//#define Interpolate(t,p1,cp1,cp2,p2) (B4(t)*p1+B3(t)*cp1+B2(t)*cp2+B1(t)*p2)
|
||||
|
||||
// Ra: "delete NULL" nic nie zrobi, więc "if (a!=NULL)" jest zbędne
|
||||
//#define SafeFree(a) if (a!=NULL) free(a)
|
||||
//#define M_PI = 3.141592653589793
|
||||
#include "stdafx.h"
|
||||
|
||||
#define SafeDelete(a) \
|
||||
{ \
|
||||
@@ -37,25 +27,26 @@ http://mozilla.org/MPL/2.0/.
|
||||
#define DegToRad(a) ((M_PI / 180.0) * (a)) //(a) w nawiasie, bo może być dodawaniem
|
||||
#define RadToDeg(r) ((180.0 / M_PI) * (r))
|
||||
|
||||
#define Fix(a, b, c) \
|
||||
{ \
|
||||
if (a < b) \
|
||||
a = b; \
|
||||
if (a > c) \
|
||||
a = c; \
|
||||
}
|
||||
|
||||
#define asModelsPath std::string("models\\")
|
||||
#define asSceneryPath std::string("scenery\\")
|
||||
//#define asTexturePath AnsiString("textures\\")
|
||||
//#define asTextureExt AnsiString(".bmp")
|
||||
#define szSceneryPath "scenery\\"
|
||||
#define szTexturePath "textures\\"
|
||||
//#define szDefaultTextureExt ".dds"
|
||||
|
||||
//#define DevelopTime //FIXME
|
||||
//#define EditorMode
|
||||
|
||||
#define MAKE_ID4(a,b,c,d) (((std::uint32_t)(d)<<24)|((std::uint32_t)(c)<<16)|((std::uint32_t)(b)<<8)|(std::uint32_t)(a))
|
||||
|
||||
template <typename _Type>
|
||||
_Type clamp( _Type const Value, _Type const Min, _Type const Max ) {
|
||||
|
||||
_Type value = Value;
|
||||
if( value < Min ) { value = Min; }
|
||||
if( value > Max ) { value = Max; }
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename _Type>
|
||||
_Type interpolate( _Type const First, _Type const Second, float const Factor ) {
|
||||
|
||||
return ( First * ( 1.0f - Factor ) ) + ( Second * Factor );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user