Kaynağa Gözat

Fixed some stuff and added some small tweaks

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 10 yıl önce
ebeveyn
işleme
a89dac5c30
15 değiştirilmiş dosya ile 120 ekleme ve 37 silme
  1. +1
    -1
      src/camera.cpp
  2. +57
    -7
      src/debug/lines.cpp
  3. +2
    -0
      src/easymesh/easymesh.cpp
  4. +0
    -6
      src/easymesh/easymesh.h
  5. +2
    -1
      src/image/codec/gdiplus-image.cpp
  6. +11
    -8
      src/image/color/color.cpp
  7. +5
    -1
      src/input/controller.h
  8. +12
    -0
      src/lol/algorithm/sort.h
  9. +1
    -0
      src/lol/base/array.h
  10. +5
    -0
      src/lol/debug/lines.h
  11. +1
    -1
      src/lol/image/color.h
  12. +12
    -0
      src/lol/math/geometry.h
  13. +7
    -4
      src/ticker.cpp
  14. +0
    -4
      src/worldentity.cpp
  15. +4
    -4
      src/worldentity.h

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

@@ -173,7 +173,7 @@ void Camera::SetPosition(vec3 pos, bool keep_target)
if (keep_target)
SetView(pos, GetTarget(), GetUp());
else
SetView(GetView() * mat4::translate(pos - m_position));
SetView(GetView() * mat4::translate(m_position - pos));
m_position = pos;
}



+ 57
- 7
src/debug/lines.cpp Dosyayı Görüntüle

@@ -98,7 +98,8 @@ vec3 Debug::ScreenToWorld(vec3 pos, mat4 view, mat4 proj)
}

//Draw stuff in World
//-- LINE: 3D -2D - 3D_to_2D
//-- LINE: 3D -2D - 3D_to_2D --------------------------------------------------

void Debug::DrawLine(vec3 a, vec3 b) { Debug::DrawLine(a, b, g_scene->GetLineColor()); }
void Debug::DrawLine(vec2 a, vec3 b, float az) { Debug::DrawLine(a, b, g_scene->GetLineColor(), az); }
void Debug::DrawLine(vec2 a, vec2 b, float az, float bz) { Debug::DrawLine(a, b, g_scene->GetLineColor(), az, bz); }
@@ -106,7 +107,56 @@ void Debug::DrawLine(vec3 a, vec3 b, vec4 color) { g_scene->A
void Debug::DrawLine(vec2 a, vec3 b, vec4 color, float az) { g_scene->AddLine(a, b, color, az); }
void Debug::DrawLine(vec2 a, vec2 b, vec4 color, float az, float bz){ g_scene->AddLine(a, b, color, az, bz); }

//-- ARROW: 3D -2D - 3D_to_2D
//-- GIZMO --------------------------------------------------------------------
void Debug::DrawGizmo(vec3 pos, vec3 x, vec3 y, vec3 z, float size)
{
Debug::DrawLine(pos, pos + x * size, Color::red);
Debug::DrawLine(pos, pos + y * size, Color::green);
Debug::DrawLine(pos, pos + z * size, Color::blue);
}
void Debug::DrawGizmo(vec2 pos, vec3 x, vec3 y, vec3 z, float size, float posz)
{
Debug::DrawLine(pos, pos + x.xy * size, Color::red, posz, posz + x.z * size);
Debug::DrawLine(pos, pos + y.xy * size, Color::green, posz, posz + y.z * size);
Debug::DrawLine(pos, pos + z.xy * size, Color::blue, posz, posz + z.z * size);
}

//-- GRID ---------------------------------------------------------------------
void Debug::DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d)
{
float seg_sz = g_scene->GetLineSegmentSize();
int seg_nb = lol::max((int)(size / seg_sz), 1);
seg_sz = size / (float)seg_nb;

//Draw Gizmo
Debug::DrawGizmo(pos, x, y, z, size);
Debug::DrawLine(pos, pos - x * size, Color::gray);
Debug::DrawLine(pos, pos - y * size, Color::gray);
Debug::DrawLine(pos, pos - z * size, Color::gray);

//grid
for (float i = -seg_nb; i <= seg_nb; i++)
{
if (i != 0)
{
float iter = seg_sz * ((float)i);
Debug::DrawLine(vec3(-size, 0, iter), vec3(size, 0, iter), Color::gray_dark);
Debug::DrawLine(vec3(iter, 0, -size), vec3(iter, 0, size), Color::gray_dark);

if (draw_3d)
{
Debug::DrawLine(vec3(0, -size, iter), vec3(0, size, iter), Color::gray_dark);
Debug::DrawLine(vec3(0, iter, -size), vec3(0, iter, size), Color::gray_dark);

Debug::DrawLine(vec3(-size, iter, 0), vec3(size, iter, 0), Color::gray_dark);
Debug::DrawLine(vec3(iter, -size, 0), vec3(iter, size, 0), Color::gray_dark);
}
}
}

}

//-- ARROW: 3D -2D - 3D_to_2D -------------------------------------------------
void Debug::DrawArrow(vec3 a, vec3 b, vec2 s) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y)); }
void Debug::DrawArrow(vec2 a, vec3 b, vec2 s, float az) { Debug::DrawArrow(a, b.xy, vec3(s.x, s.y, s.y), az, b.z); }
void Debug::DrawArrow(vec2 a, vec2 b, vec2 s, float az, float bz) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y), az, bz); }
@@ -161,7 +211,7 @@ void Debug::DrawArrow(vec2 a, vec2 b, vec3 s, vec4 color, float az, float bz)
Debug::DrawLine(b - (z + y).xy, b - (z - y).xy, color, bz - (z + y).z, bz - (z - y).z);
}

//-- BOX: 3D -2D - 3D_to_2D
//-- BOX: 3D -2D - 3D_to_2D ---------------------------------------------------
void Debug::DrawBox(box3 a) { Debug::DrawBox(a.A, a.B, g_scene->GetLineColor()); }
void Debug::DrawBox(box2 a) { Debug::DrawBox(a.A, a.B, g_scene->GetLineColor()); }
void Debug::DrawBox(box3 a, vec4 color) { Debug::DrawBox(a.A, a.B, color); }
@@ -219,7 +269,7 @@ void Debug::DrawBox(vec2 a, float s, mat2 transform, vec4 color)
Debug::DrawBox(a - b, a + b, transform, color);
}

//-- CIRCLE
//-- CIRCLE -------------------------------------------------------------------
void Debug::DrawCircle(vec2 a, float s) { Debug::DrawCircle(a, s * vec2(1.f, g_renderer->GetXYRatio()), g_scene->GetLineColor()); }
void Debug::DrawCircle(vec3 a, vec3 n) { Debug::DrawCircle(a, n, g_scene->GetLineColor()); }
void Debug::DrawCircle(vec2 a, vec2 s) { Debug::DrawCircle(a, s * vec2(1.f, g_renderer->GetXYRatio()), g_scene->GetLineColor()); }
@@ -274,7 +324,7 @@ void Debug::DrawCircle(vec2 a, vec2 x, vec2 y, vec4 color)
}
}

//-- SPHERE
//-- SPHERE -------------------------------------------------------------------
void Debug::DrawSphere(vec3 a, float s) { Debug::DrawSphere(a, s, g_scene->GetLineColor()); }
void Debug::DrawSphere(vec3 a, float s, vec4 color) { Debug::DrawSphere(a, vec3::axis_x * s, vec3::axis_y * s, vec3::axis_z * s, color); }
void Debug::DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z) { Debug::DrawSphere(a, x, y, z, g_scene->GetLineColor()); }
@@ -291,7 +341,7 @@ void Debug::DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z, vec4 color)
Debug::DrawCircle(a, y, (z - x) * .707f, color);
}

//-- CAPSULE
//-- CAPSULE ------------------------------------------------------------------
void Debug::DrawCapsule(vec3 a, float s, vec3 h) { Debug::DrawCapsule(a, s, h, g_scene->GetLineColor()); }
void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h) { Debug::DrawCapsule(a, x, y, z, h, g_scene->GetLineColor()); }
void Debug::DrawCapsule(vec3 a, float s, vec3 h, vec4 color)
@@ -327,7 +377,7 @@ void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, vec4 color)
}
}

//-- VIEW PROJ
//-- VIEW PROJ ----------------------------------------------------------------
void Debug::DrawViewProj(mat4 view, mat4 proj) { Debug::DrawViewProj(view, proj, g_scene->GetLineColor()); }
void Debug::DrawViewProj(mat4 view_proj) { Debug::DrawViewProj(view_proj, g_scene->GetLineColor()); }
void Debug::DrawViewProj(mat4 view, mat4 proj, vec4 color)


+ 2
- 0
src/easymesh/easymesh.cpp Dosyayı Görüntüle

@@ -103,6 +103,8 @@ void EasyMesh::MeshConvert()
m_submeshes.Push(new SubMesh(shader, vdecl));
m_submeshes.Last()->SetIndexBuffer(ibo);
m_submeshes.Last()->SetVertexBuffer(0, vbo);

m_state = MeshRender::CanRender;
}

//-----------------------------------------------------------------------------


+ 0
- 6
src/easymesh/easymesh.h Dosyayı Görüntüle

@@ -33,12 +33,6 @@ LOL_SAFE_ENUM(CSGUsage,
Xor
);

LOL_SAFE_ENUM(Axis,
X,
Y,
Z
);

LOL_SAFE_ENUM(MeshTransform,
Taper,
Twist,


+ 2
- 1
src/image/codec/gdiplus-image.cpp Dosyayı Görüntüle

@@ -207,11 +207,12 @@ bool GdiPlusImageCodec::Save(Image *image, char const *path)
}

u8vec4 *psrc = image->Lock<PixelFormat::RGBA_8>();
u8vec4 *psrc0 = psrc;
u8vec4 *pdst = static_cast<u8vec4 *>(bdata.Scan0);
for (int y = 0; y < size.y; y++)
for (int x = 0; x < size.x; x++)
*pdst++ = (*psrc++).bgra;
image->Unlock(pdst);
image->Unlock(psrc0);
b->UnlockBits(&bdata);

if (b->Save(wpath, &clsid, nullptr) != Gdiplus::Ok)


+ 11
- 8
src/image/color/color.cpp Dosyayı Görüntüle

@@ -16,14 +16,17 @@ namespace lol
/*
* Hardcoded constants for colours
*/
vec4 const Color::black = vec4(0, 0, 0, 1);
vec4 const Color::red = vec4(1, 0, 0, 1);
vec4 const Color::green = vec4(0, 1, 0, 1);
vec4 const Color::yellow = vec4(1, 1, 0, 1);
vec4 const Color::blue = vec4(0, 0, 1, 1);
vec4 const Color::magenta = vec4(1, 0, 1, 1);
vec4 const Color::cyan = vec4(0, 1, 1, 1);
vec4 const Color::white = vec4(1, 1, 1, 1);
vec4 const Color::black = vec4(0, 0, 0, 1);
vec4 const Color::red = vec4(1, 0, 0, 1);
vec4 const Color::green = vec4(0, 1, 0, 1);
vec4 const Color::yellow = vec4(1, 1, 0, 1);
vec4 const Color::blue = vec4(0, 0, 1, 1);
vec4 const Color::magenta = vec4(1, 0, 1, 1);
vec4 const Color::cyan = vec4(0, 1, 1, 1);
vec4 const Color::white = vec4(1, 1, 1, 1);
vec4 const Color::gray_dark = vec4(.25f, .25f, .25f, 1);
vec4 const Color::gray = vec4(.5f, .5f, .5f, 1);
vec4 const Color::gray_light= vec4(.75f, .75f, .75f, 1);

/*
* Conversion from colours to hexadecimal


+ 5
- 1
src/input/controller.h Dosyayı Görüntüle

@@ -114,7 +114,11 @@ public:


protected:
void Update() { m_previous = m_current; m_current = IsBound() ? RetrieveCurrentValue() : 0.0f; }
void Update()
{
m_previous = m_current;
m_current = IsBound() ? RetrieveCurrentValue() : 0.0f;
}
float RetrieveCurrentValue();

/** m1 is the InputDevice, m2 is the axis index on the InputDevice, m3 and m4 are an optional key indices to bind one or two keys over the axis */


+ 12
- 0
src/lol/algorithm/sort.h Dosyayı Görüntüle

@@ -16,6 +16,18 @@
namespace lol
{

template<typename T, typename ARRAY>
void array_base<T, ARRAY>::Shuffle()
{
auto n = Count();
auto ni = n;
while (n > 0)
{
ni = lol::rand(n--) | 0;
Swap(ni, n);
}
}

template<typename T, typename ARRAY>
void array_base<T, ARRAY>::Sort(int sort)
{


+ 1
- 0
src/lol/base/array.h Dosyayı Görüntüle

@@ -368,6 +368,7 @@ public:
m_reserved = toreserve;
}

void Shuffle();
void Sort(int sort);
void SortQuickSwap(ptrdiff_t start, ptrdiff_t stop);



+ 5
- 0
src/lol/debug/lines.h Dosyayı Görüntüle

@@ -51,6 +51,11 @@ void DrawLine(vec2 a, vec2 b, float az=-1.f, float bz=-1.f);
void DrawLine(vec3 a, vec3 b, vec4 color);
void DrawLine(vec2 a, vec3 b, vec4 color, float az=-1.f);
void DrawLine(vec2 a, vec2 b, vec4 color, float az=-1.f, float bz=-1.f);
//-- GIZMO
void DrawGizmo(vec3 pos, vec3 x, vec3 y, vec3 z, float size);
void DrawGizmo(vec2 pos, vec3 x, vec3 y, vec3 z, float size, float posz = -1.f);
//-- GRID
void DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d=false);
//-- ARROW
void DrawArrow(vec3 a, vec3 b, vec2 s);
void DrawArrow(vec2 a, vec3 b, vec2 s, float az=-1.f);


+ 1
- 1
src/lol/image/color.h Dosyayı Görüntüle

@@ -327,7 +327,7 @@ public:
/*
* Some predefined colours
*/
static const vec4 black, red, green, yellow, blue, magenta, cyan, white;
static const vec4 black, red, green, yellow, blue, magenta, cyan, white, gray_dark, gray, gray_light;
};

} /* namespace lol */


+ 12
- 0
src/lol/math/geometry.h Dosyayı Görüntüle

@@ -26,6 +26,18 @@
namespace lol
{

struct AxisBase
{
enum Type
{
X = 0, Y, Z, MAX, XY = 2, XYZ = 3,
};
protected:
static inline char const *GetDescription() { return "X,Y,Z,MAX,XY,XYZ"; }
static inline char const **GetCustomString() { return nullptr; }
};
typedef SafeEnum<AxisBase> Axis;

#define LOL_BOX_TYPEDEFS(tname, suffix) \
template <typename T> struct tname; \
typedef tname<float> suffix; \


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

@@ -339,8 +339,9 @@ void TickerData::GameThreadTick()
}

/* Tick objects for the game loop */
for (int g = Entity::GAMEGROUP_BEGIN; g < Entity::GAMEGROUP_END; ++g)
for (int i = 0; i < data->m_list[g].Count(); ++i)
for (int g = Entity::GAMEGROUP_BEGIN; g < Entity::GAMEGROUP_END && !data->quit /* Stop as soon as required */; ++g)
{
for (int i = 0; i < data->m_list[g].Count() && !data->quit /* Stop as soon as required */; ++i)
{
Entity *e = data->m_list[g][i];

@@ -361,6 +362,7 @@ void TickerData::GameThreadTick()
#endif
}
}
}

Profiler::Stop(Profiler::STAT_TICK_GAME);
}
@@ -370,7 +372,7 @@ void TickerData::DrawThreadTick()
Profiler::Start(Profiler::STAT_TICK_DRAW);

/* Tick objects for the draw loop */
for (int g = Entity::DRAWGROUP_BEGIN; g < Entity::DRAWGROUP_END; ++g)
for (int g = Entity::DRAWGROUP_BEGIN; g < Entity::DRAWGROUP_END && !data->quit /* Stop as soon as required */; ++g)
{
switch (g)
{
@@ -382,7 +384,8 @@ void TickerData::DrawThreadTick()
break;
}

for (int i = 0; i < data->m_list[g].Count(); ++i)
//Stop as soon as required
for (int i = 0; i < data->m_list[g].Count() && !data->quit /* Stop as soon as required */; ++i)
{
Entity *e = data->m_list[g][i];



+ 0
- 4
src/worldentity.cpp Dosyayı Görüntüle

@@ -21,10 +21,6 @@ namespace lol

WorldEntity::WorldEntity()
{
m_position = vec3::zero;
m_rotation = quat(1);
m_velocity = vec3::zero;
m_rotation_velocity = vec3::zero;
m_bbox[0] = m_bbox[1] = vec3::zero;
}



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

@@ -28,10 +28,10 @@ public:
virtual char const *GetName();

public:
vec3 m_position;
vec3 m_velocity;
quat m_rotation;
vec3 m_rotation_velocity;
vec3 m_position = vec3::zero;
vec3 m_velocity = vec3::zero;
quat m_rotation = quat(1);
vec3 m_rotation_velocity = vec3::zero;
vec3 m_bbox[2];

protected:


Yükleniyor…
İptal
Kaydet