Kaynağa Gözat

Rename Float3 to float3, Int3 to int3 etc. and add the 4-member versions.

legacy
Sam Hocevar sam 14 yıl önce
ebeveyn
işleme
f76b95f200
9 değiştirilmiş dosya ile 46 ekleme ve 28 silme
  1. +1
    -1
      src/debugfps.cpp
  2. +5
    -5
      src/emitter.cpp
  3. +2
    -2
      src/emitter.h
  4. +7
    -7
      src/input.cpp
  5. +4
    -4
      src/input.h
  6. +22
    -4
      src/matrix.h
  7. +1
    -1
      src/sdlinput.cpp
  8. +3
    -3
      src/text.cpp
  9. +1
    -1
      src/text.h

+ 1
- 1
src/debugfps.cpp Dosyayı Görüntüle

@@ -39,7 +39,7 @@ DebugFps::DebugFps(int x, int y)
for (int i = 0; i < 5; i ++)
{
data->lines[i] = new Text(NULL, "gfx/font/ascii.png");
data->lines[i]->SetPos(Int3(x, y + (i ? 8 : 0) + 16 * i, 0));
data->lines[i]->SetPos(int3(x, y + (i ? 8 : 0) + 16 * i, 0));
Ticker::Ref(data->lines[i]);
}
}


+ 5
- 5
src/emitter.cpp Dosyayı Görüntüle

@@ -27,10 +27,10 @@ class EmitterData

private:
int tiler;
Float3 gravity;
float3 gravity;
int particles[100];
Float3 positions[100];
Float3 velocities[100];
float3 positions[100];
float3 velocities[100];
int nparticles;
};

@@ -38,7 +38,7 @@ private:
* Public Emitter class
*/

Emitter::Emitter(int tiler, Float3 gravity)
Emitter::Emitter(int tiler, float3 gravity)
: data(new EmitterData())
{
data->tiler = tiler;
@@ -75,7 +75,7 @@ void Emitter::TickDraw(float deltams)
data->positions[i].z, 0);
}

void Emitter::AddParticle(int id, Float3 pos, Float3 vel)
void Emitter::AddParticle(int id, float3 pos, float3 vel)
{
if (data->nparticles >= 100)
return;


+ 2
- 2
src/emitter.h Dosyayı Görüntüle

@@ -23,10 +23,10 @@ class EmitterData;
class Emitter : public Entity
{
public:
Emitter(int tiler, Float3 gravity);
Emitter(int tiler, float3 gravity);
virtual ~Emitter();

void AddParticle(int id, Float3 pos, Float3 vel);
void AddParticle(int id, float3 pos, float3 vel);

protected:
virtual void TickGame(float deltams);


+ 7
- 7
src/input.cpp Dosyayı Görüntüle

@@ -34,8 +34,8 @@ public:
buttons(0, 0, 0)
{ }

Int2 mouse;
Int3 buttons;
int2 mouse;
int3 buttons;
}
inputdata;

@@ -45,10 +45,10 @@ static InputData * const data = &inputdata;
* Public Input class
*/

Float2 Input::GetAxis(int axis)
float2 Input::GetAxis(int axis)
{
float invsqrt2 = sqrtf(0.5f);
Float2 f;
float2 f;

/* Simulate a joystick using the keyboard. This SDL call is free. */
Uint8 *keystate = SDL_GetKeyState(NULL);
@@ -65,12 +65,12 @@ Float2 Input::GetAxis(int axis)
return f;
}

void Input::SetMousePos(Int2 coord)
void Input::SetMousePos(int2 coord)
{
data->mouse = coord;
}

Int2 Input::GetMousePos()
int2 Input::GetMousePos()
{
return data->mouse;
}
@@ -85,7 +85,7 @@ void Input::UnsetMouseButton(int index)
data->buttons[index] = 0;
}

Int3 Input::GetMouseButtons()
int3 Input::GetMouseButtons()
{
return data->buttons;
}


+ 4
- 4
src/input.h Dosyayı Görüntüle

@@ -21,12 +21,12 @@
class Input
{
public:
static Float2 GetAxis(int axis);
static void SetMousePos(Int2 coord);
static Int2 GetMousePos();
static float2 GetAxis(int axis);
static void SetMousePos(int2 coord);
static int2 GetMousePos();
static void SetMouseButton(int index);
static void UnsetMouseButton(int index);
static Int3 GetMouseButtons();
static int3 GetMouseButtons();
};

#endif // __DH_INPUT_H__


+ 22
- 4
src/matrix.h Dosyayı Görüntüle

@@ -97,8 +97,8 @@ template <typename T> struct Vec2
union { T y; T b; T j; };
};

typedef Vec2<float> Float2;
typedef Vec2<int> Int2;
typedef Vec2<float> float2;
typedef Vec2<int> int2;

template <typename T> struct Vec3
{
@@ -113,8 +113,25 @@ template <typename T> struct Vec3
union { T z; T c; T k; };
};

typedef Vec3<float> Float3;
typedef Vec3<int> Int3;
typedef Vec3<float> float3;
typedef Vec3<int> int3;

template <typename T> struct Vec4
{
inline Vec4() { x = y = z = w = 0; }
inline Vec4(T val) { x = y = z = w = val; }
inline Vec4(T _x, T _y, T _z, T _w) { x = _x; y = _y; z = _z; w = _w; }

OPERATORS(4)

union { T x; T a; T i; };
union { T y; T b; T j; };
union { T z; T c; T k; };
union { T w; T d; T l; };
};

typedef Vec4<float> float4;
typedef Vec4<int> int4;

#define SCALAR_GLOBAL(elems, op, U) \
template<typename T> \
@@ -139,6 +156,7 @@ typedef Vec3<int> Int3;

GLOBALS(2)
GLOBALS(3)
GLOBALS(4)

#endif // __DH_MATRIX_H__


+ 1
- 1
src/sdlinput.cpp Dosyayı Görüntüle

@@ -48,7 +48,7 @@ void SdlInput::TickGame(float deltams)
Entity::TickGame(deltams);

/* Handle mouse input */
Int2 mouse;
int2 mouse;
if (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
{
SDL_GetMouseState(&mouse.x, &mouse.y);


+ 3
- 3
src/text.cpp Dosyayı Görüntüle

@@ -29,7 +29,7 @@ class TextData
private:
int font;
char *text;
Int3 pos;
int3 pos;
};

/*
@@ -41,7 +41,7 @@ Text::Text(char const *text, char const *font)
{
data->font = Forge::Register(font);
data->text = text ? strdup(text) : NULL;
data->pos = Int3(0, 0, 0);
data->pos = int3(0, 0, 0);

drawgroup = DRAWGROUP_HUD;
}
@@ -53,7 +53,7 @@ void Text::SetText(char const *text)
data->text = text ? strdup(text) : NULL;
}

void Text::SetPos(Int3 pos)
void Text::SetPos(int3 pos)
{
data->pos = pos;
}


+ 1
- 1
src/text.h Dosyayı Görüntüle

@@ -27,7 +27,7 @@ public:
virtual ~Text();

void SetText(char const *text);
void SetPos(Int3 pos);
void SetPos(int3 pos);

protected:
virtual void TickDraw(float deltams);


Yükleniyor…
İptal
Kaydet