Wireframe is back for normal OGL users MV : Added timed command execution for future "demo mode"undefined
@@ -96,6 +96,8 @@ DefaultShaderData::DefaultShaderData(DebugRenderMode render_mode) | |||
if (render_mode == DebugRenderMode::Default) | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(shiny)); | |||
else if (render_mode == DebugRenderMode::Flat) | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(shinyflat)); | |||
else if (render_mode == DebugRenderMode::Wireframe) | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(shinydebugwireframe)); | |||
else if (render_mode == DebugRenderMode::Lighting) | |||
@@ -434,12 +436,13 @@ EasyMesh::EasyMesh() | |||
//----------------------------------------------------------------------------- | |||
EasyMesh::EasyMesh(const EasyMesh& em) | |||
{ | |||
//*this = em; | |||
m_indices = em.m_indices; | |||
m_vert = em.m_vert; | |||
m_cursors = em.m_cursors; | |||
m_build_data = nullptr; | |||
m_gpu_data = GpuEasyMeshData(); | |||
if (em.m_build_data) | |||
m_build_data = new EasyMeshBuildData(*em.m_build_data); | |||
if (m_indices.Count() && m_vert.Count() && m_cursors.Count()) | |||
m_state = MeshRender::NeedConvert; | |||
else | |||
@@ -447,7 +450,7 @@ EasyMesh::EasyMesh(const EasyMesh& em) | |||
} | |||
//----------------------------------------------------------------------------- | |||
bool EasyMesh::Compile(char const *command) | |||
bool EasyMesh::Compile(char const *command, bool Execute) | |||
{ | |||
bool res = false; | |||
EasyMeshCompiler mc(*this); | |||
@@ -455,18 +458,8 @@ bool EasyMesh::Compile(char const *command) | |||
if ((res = mc.ParseString(command))) | |||
{ | |||
BD()->Disable(MeshBuildOperation::CommandRecording); | |||
BD()->Enable(MeshBuildOperation::CommandExecution); | |||
ExecuteCmdStack(); | |||
BD()->Disable(MeshBuildOperation::CommandExecution); | |||
if (!BD()->IsEnabled(MeshBuildOperation::PreventVertCleanup)) | |||
VerticesCleanup(); | |||
if (BD()->IsEnabled(MeshBuildOperation::PostBuildComputeNormals)) | |||
ComputeNormals(0, m_indices.Count()); | |||
BD()->Disable(MeshBuildOperation::PostBuildComputeNormals); | |||
BD()->Disable(MeshBuildOperation::PreventVertCleanup); | |||
if (Execute) | |||
ExecuteCmdStack(); | |||
} | |||
return res; | |||
} | |||
@@ -502,14 +495,21 @@ bool EasyMesh::Compile(char const *command) | |||
LOL_CALL(LOL_CAT(EZCALL_, LOL_CALL(LOL_COUNT_TO_12, (__VA_ARGS__))), (__VA_ARGS__)) | |||
//----------------------------------------------------------------------------- | |||
void EasyMesh::ExecuteCmdStack() | |||
void EasyMesh::ExecuteCmdStack(bool ExecAllStack) | |||
{ | |||
#define DO_EXEC_CMD(MESH_CMD, FUNC_PARAMS) \ | |||
case EasyMeshCmdType::MESH_CMD: \ | |||
{ EZM_CALL_FUNC FUNC_PARAMS; break; } | |||
for (BD()->Cmdi() = 0; BD()->Cmdi() < BD()->CmdStack().GetCmdNb(); ++BD()->Cmdi()) | |||
BD()->Enable(MeshBuildOperation::CommandExecution); | |||
if (ExecAllStack) | |||
BD()->Cmdi() = 0; | |||
for (; BD()->Cmdi() < BD()->CmdStack().GetCmdNb() && BD()->CmdExecNb() != 0; ++BD()->Cmdi()) | |||
{ | |||
if (BD()->CmdExecNb() > 0) | |||
--BD()->CmdExecNb(); | |||
switch (BD()->CmdStack().GetCmd(BD()->Cmdi())) | |||
{ | |||
DO_EXEC_CMD(MeshCsg, (MeshCsg, CSGUsage)) | |||
@@ -549,6 +549,19 @@ void EasyMesh::ExecuteCmdStack() | |||
ASSERT(0, "Unknown command pseudo bytecode"); | |||
} | |||
} | |||
BD()->Disable(MeshBuildOperation::CommandExecution); | |||
if (!BD()->IsEnabled(MeshBuildOperation::PreventVertCleanup)) | |||
VerticesCleanup(); | |||
if (BD()->IsEnabled(MeshBuildOperation::PostBuildComputeNormals)) | |||
ComputeNormals(0, m_indices.Count()); | |||
BD()->Disable(MeshBuildOperation::PostBuildComputeNormals); | |||
BD()->Disable(MeshBuildOperation::PreventVertCleanup); | |||
if (BD()->CmdExecNb() > 0) | |||
BD()->CmdExecNb() = -1; | |||
} | |||
//----------------------------------------------------------------------------- | |||
@@ -859,10 +872,10 @@ void VertexDictionnary::RemoveVertex(const int vert_id) | |||
if (jf < 0) | |||
{ | |||
jf = i; | |||
vertex_list[i].m3 == VDictType::Master; | |||
vertex_list[i].m3 = VDictType::Master; | |||
} | |||
else | |||
vertex_list[i].m3 == jf; | |||
vertex_list[i].m3 = jf; | |||
} | |||
} | |||
} | |||
@@ -32,8 +32,7 @@ private: | |||
int m_i_cur; | |||
public: | |||
//cmd storage | |||
void AddCmd(int cmd) { m_commands.Push(cmd, m_floats.Count(), m_ints.Count()); } | |||
//GET/SET exec | |||
int GetCmdNb() { return m_commands.Count(); } | |||
int GetCmd(int i) | |||
{ | |||
@@ -43,6 +42,9 @@ public: | |||
return m_commands[i].m1; | |||
} | |||
//cmd storage | |||
void AddCmd(int cmd) { m_commands.Push(cmd, m_floats.Count(), m_ints.Count()); } | |||
//GETTER | |||
inline float F() { return m_floats[m_f_cur++]; } | |||
inline int I() { return m_ints[m_i_cur++]; } | |||
@@ -373,6 +375,8 @@ public: | |||
m_texcoord_scale = vec2(1.f); | |||
m_texcoord_scale2 = vec2(1.f); | |||
m_build_flags = 0; | |||
m_i_cmd = 0; | |||
m_exec_nb = -1; | |||
for (int i = 0; i < MeshType::Max; ++i) | |||
{ | |||
m_texcoord_build_type[i] = TexCoordBuildType::TriangleDefault; | |||
@@ -381,7 +385,8 @@ public: | |||
} | |||
inline CommandStack &CmdStack() { return m_stack; } | |||
inline int &Cmdi() { return m_cmd_i; } | |||
inline int &Cmdi() { return m_i_cmd; } | |||
inline int &CmdExecNb() { return m_exec_nb; } | |||
inline Array<int, int> &LoopStack(){ return m_loop_stack; } | |||
inline vec4 &ColorA() { return m_color_a; } | |||
inline vec4 &ColorB() { return m_color_b; } | |||
@@ -570,7 +575,8 @@ public: | |||
public: | |||
CommandStack m_stack; | |||
int m_cmd_i; | |||
int m_i_cmd; | |||
int m_exec_nb; | |||
Array<int, int> m_loop_stack; | |||
vec4 m_color_a; | |||
vec4 m_color_b; | |||
@@ -667,8 +673,8 @@ public: | |||
EasyMesh(); | |||
EasyMesh(const EasyMesh& em); | |||
bool Compile(char const *command); | |||
void ExecuteCmdStack(); | |||
bool Compile(char const *command, bool Execute=true); | |||
void ExecuteCmdStack(bool ExecAllStack=true); | |||
void MeshConvert(GpuShaderData* new_gpu_sdata); | |||
void MeshConvert(Shader* ProvidedShader = nullptr); | |||
bool Render(mat4 const &model, int render_mode=Video::GetDebugRenderMode()); | |||
@@ -63,42 +63,26 @@ void Video::SetDebugRenderMode(DebugRenderMode d) | |||
{ | |||
//All these modes are handled in the shaders. | |||
case DebugRenderMode::Default: | |||
case DebugRenderMode::Flat: | |||
case DebugRenderMode::Lighting: | |||
case DebugRenderMode::Normal: | |||
case DebugRenderMode::UV: | |||
{ | |||
#if defined USE_D3D9 || defined _XBOX | |||
#elif defined HAVE_GLES_2X | |||
// glEnable(GL_CULL_FACE); | |||
#else | |||
// if (VideoData::render_mode == d && glIsEnabled(GL_CULL_FACE) == GL_TRUE) | |||
// SetFaceCulling(false); | |||
// else | |||
// SetFaceCulling(true); | |||
// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | |||
glEnable(GL_CULL_FACE); | |||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | |||
#endif | |||
break; | |||
} | |||
case DebugRenderMode::Wireframe: | |||
{ | |||
if (VideoData::render_mode == d) | |||
{ | |||
#if defined USE_D3D9 || defined _XBOX | |||
#else | |||
// SetFaceCulling(!VideoData::face_culling); | |||
#endif | |||
} | |||
else | |||
{ | |||
#if defined USE_D3D9 || defined _XBOX | |||
#else | |||
// SetFaceCulling(false); | |||
#endif | |||
} | |||
#if defined USE_D3D9 || defined _XBOX | |||
#elif defined HAVE_GLES_2X | |||
#else | |||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | |||
glDisable(GL_CULL_FACE); | |||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | |||
#endif | |||
break; | |||
} | |||
@@ -28,6 +28,7 @@ struct DebugRenderMode | |||
{ | |||
//Add your new rendermode at your convenience | |||
Default, | |||
Flat, | |||
Wireframe, | |||
Lighting, | |||
Normal, | |||
@@ -1,6 +1,6 @@ | |||
addlight 0 position (1 -.5 1.5) color #bbb addlight 0 position (-1 -.5 -1.5) color #bbb addlight 1 position (0 1 0) color #444 | |||
clearcolor #ddd | |||
showgizmo false | |||
showgizmo true | |||
showlight false | |||
@@ -48,8 +48,10 @@ custom setmesh " | |||
//sc#0f0 ab 2 ty 1.5 ab 2 | |||
//sc#00f ab 2 ty 1.5 ab 2 | |||
sc#00f tqw lp 5[tz 11 [lp 6 [tx 5 ty 5 ab 10 ]]] tz -22 | |||
[sc#66f afcb(10) .25tx0]csgs[sc#fff afcb(10).25t(2)][[sc#6f6 afcb(7).25]csgs[sc#fff afcb(7).25t(1.5)]][[sc#f44 asph4 12t(-2.5)]csga[sc#fff afcb(7).25t(1.4)]csgs[sc#fff afcb(7).25t(2.5)]][[sc#ff0 ato6 2.5 1.2rx90tz-1.25tx-.9][sc#ff0 ab.5 2.1 .5dup[rz90sx.5ty-.8tx-.28]ty.55tx.25tz-.4taz1 1sy.8sx.8ty-.55tx-.25tz.4tz-1.2tx1.2]tz1.25tx1.25dup[sx-1ry90]tz-1.25tx-1.25] | |||
//[sc#66f afcb(10) .25tx0]csgs[sc#fff afcb(10).25t(2)][[sc#6f6 afcb(7).25]csgs[sc#fff afcb(7).25t(1.5)]][[sc#f44 asph4 12t(-2.5)]csga[sc#fff afcb(7).25t(1.4)]csgs[sc#fff afcb(7).25t(2.5)]][[sc#ff0 ato6 2.5 1.2rx90tz-1.25tx-.9][sc#ff0 ab.5 2.1 .5dup[rz90sx.5ty-.8tx-.28]ty.55tx.25tz-.4taz1 1sy.8sx.8ty-.55tx-.25tz.4tz-1.2tx1.2]tz1.25tx1.25dup[sx-1ry90]tz-1.25tx-1.25] | |||
" | |||
@@ -166,6 +166,7 @@ public: | |||
// Mesh Setup | |||
m_render_max = vec2(-.9f, 4.1f); | |||
m_mesh_render = 0; | |||
m_mesh_id = 0; | |||
m_mesh_id1 = 0.f; | |||
m_default_texture = nullptr; | |||
@@ -194,6 +195,9 @@ public: | |||
m_mat_prev = mat4(quat::fromeuler_xyz(vec3::zero)); | |||
m_mat = mat4(quat::fromeuler_xyz(vec3(m_rot_mesh, .0f))); | |||
m_build_timer = 0.1f; | |||
m_build_time = -1.f; | |||
//stream update | |||
m_stream_update_time = 2.0f; | |||
m_stream_update_timer = 1.0f; | |||
@@ -297,7 +301,7 @@ public: | |||
{ | |||
if (m_mesh_id == m_meshes.Count() - 1) | |||
m_mesh_id++; | |||
m_meshes.Push(em); | |||
m_meshes.Push(em, nullptr); | |||
} | |||
#else | |||
m_ssetup->Compile("addlight 0.0 position (4 -1 -4) color (.0 .2 .5 1) " | |||
@@ -461,8 +465,8 @@ public: | |||
//Target List Setup | |||
Array<vec3> target_list; | |||
if (m_meshes.Count() && m_mesh_id >= 0) | |||
for (int i = 0; i < m_meshes[m_mesh_id]->GetVertexCount(); i++) | |||
target_list << (m_mat * mat4::translate(m_meshes[m_mesh_id]->GetVertexLocation(i))).v3.xyz; | |||
for (int i = 0; i < m_meshes[m_mesh_id].m1->GetVertexCount(); i++) | |||
target_list << (m_mat * mat4::translate(m_meshes[m_mesh_id].m1->GetVertexLocation(i))).v3.xyz; | |||
//-- | |||
//Update mesh screen location - Get the Min/Max needed | |||
@@ -582,11 +586,12 @@ public: | |||
{ | |||
//Create a new mesh | |||
EasyMesh* em = new EasyMesh(); | |||
if (em->Compile(m_ssetup->m_custom_cmd[i].m2.C())) | |||
if (em->Compile(m_ssetup->m_custom_cmd[i].m2.C(), false)) | |||
{ | |||
em->BD()->Cmdi() = 0; | |||
if (m_mesh_id == m_meshes.Count() - 1) | |||
m_mesh_id++; | |||
m_meshes.Push(em); | |||
m_meshes.Push(em, nullptr); | |||
} | |||
else | |||
delete(em); | |||
@@ -645,16 +650,10 @@ public: | |||
//TODO : This should probably be "standard LoL behaviour" | |||
#if NO_NACL_EM_INPUT | |||
{ | |||
if (KeyReleased(KEY_F1)) | |||
Video::SetDebugRenderMode(DebugRenderMode::Default); | |||
if (KeyReleased(KEY_F2)) | |||
Video::SetDebugRenderMode(DebugRenderMode::Wireframe); | |||
if (KeyReleased(KEY_F3)) | |||
Video::SetDebugRenderMode(DebugRenderMode::Lighting); | |||
if (KeyReleased(KEY_F4)) | |||
Video::SetDebugRenderMode(DebugRenderMode::Normal); | |||
if (KeyReleased(KEY_F5)) | |||
Video::SetDebugRenderMode(DebugRenderMode::UV); | |||
Video::SetDebugRenderMode((Video::GetDebugRenderMode() + 1) % DebugRenderMode::Max); | |||
else if (KeyReleased(KEY_F1)) | |||
Video::SetDebugRenderMode((Video::GetDebugRenderMode() + DebugRenderMode::Max - 1) % DebugRenderMode::Max); | |||
} | |||
#endif //NO_NACL_EM_INPUT | |||
@@ -679,6 +678,63 @@ public: | |||
break; | |||
} | |||
if (m_build_timer > .0f) | |||
{ | |||
if (m_build_time < .0f) | |||
{ | |||
m_build_time = m_build_timer; | |||
for (int i = 0; i < m_meshes.Count(); ++i) | |||
{ | |||
if (m_meshes[i].m1 && m_meshes[i].m1->BD()->Cmdi() < m_meshes[i].m1->BD()->CmdStack().GetCmdNb()) | |||
{ | |||
EasyMesh* tmp = m_meshes[i].m1; | |||
EasyMesh* newtmp = new EasyMesh(*tmp); | |||
int ii = 1; | |||
#if 1 | |||
bool stop = false; | |||
while (!stop) | |||
{ | |||
int cmdi = newtmp->BD()->Cmdi() + ii; | |||
if (cmdi < newtmp->BD()->CmdStack().GetCmdNb()) | |||
{ | |||
switch (newtmp->BD()->CmdStack().GetCmd(cmdi)) | |||
{ | |||
case EasyMeshCmdType::LoopStart: | |||
case EasyMeshCmdType::LoopEnd: | |||
case EasyMeshCmdType::OpenBrace: | |||
case EasyMeshCmdType::CloseBrace: | |||
case EasyMeshCmdType::ScaleWinding: | |||
case EasyMeshCmdType::QuadWeighting: | |||
case EasyMeshCmdType::PostBuildNormal: | |||
case EasyMeshCmdType::PreventVertCleanup: | |||
case EasyMeshCmdType::SetColorA: | |||
case EasyMeshCmdType::SetColorB: | |||
{ | |||
ii++; | |||
break; | |||
} | |||
default: | |||
{ | |||
stop = true; | |||
break; | |||
} | |||
} | |||
} | |||
else | |||
stop = true; | |||
} | |||
#endif | |||
newtmp->BD()->CmdExecNb() = ii; | |||
newtmp->ExecuteCmdStack(false); | |||
m_meshes[i].m1 = newtmp; | |||
delete(tmp); | |||
} | |||
} | |||
} | |||
m_build_time -= seconds; | |||
} | |||
vec3 x = vec3(1.f,0.f,0.f); | |||
vec3 y = vec3(0.f,1.f,0.f); | |||
mat4 save_proj = m_camera->GetProjection(); | |||
@@ -692,21 +748,21 @@ public: | |||
for (int i = 0; i < m_meshes.Count(); i++) | |||
{ | |||
{ | |||
if (m_meshes[i]->GetMeshState() == MeshRender::NeedConvert) | |||
if (m_meshes[i].m1->GetMeshState() == MeshRender::NeedConvert) | |||
{ | |||
#if WITH_TEXTURE | |||
m_meshes[i]->MeshConvert(new DefaultShaderData(((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) | | |||
(1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)), | |||
m_texture_shader, true)); | |||
m_meshes[i].m1->MeshConvert(new DefaultShaderData(((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) | | |||
(1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)), | |||
m_texture_shader, true)); | |||
#else | |||
m_meshes[i]->MeshConvert(); | |||
m_meshes[i].m1->MeshConvert(); | |||
#endif //WITH_TEXTURE | |||
} | |||
#if ALL_FEATURES | |||
float j = -(float)(m_meshes.Count() - (i + 1)) + (-m_mesh_id1 + (float)(m_meshes.Count() - 1)); | |||
if (m_mesh_id1 - m_render_max[0] > (float)i && m_mesh_id1 - m_render_max[1] < (float)i && | |||
m_meshes[i]->GetMeshState() > MeshRender::NeedConvert) | |||
m_meshes[i].m1->GetMeshState() > MeshRender::NeedConvert) | |||
{ | |||
float a_j = lol::abs(j); | |||
float i_trans = (a_j * a_j * m_hist_scale_mesh.x + a_j * m_hist_scale_mesh.x) * .5f; | |||
@@ -720,12 +776,12 @@ public: | |||
//Camera projection | |||
mat4 new_proj = mat_obj_offset * mat_count_offset * mat_align * mat_count_scale * save_proj; | |||
m_camera->SetProjection(new_proj); | |||
m_meshes[i]->Render(m_mat); | |||
m_meshes[i].m1->Render(m_mat); | |||
g_renderer->Clear(ClearMask::Depth); | |||
} | |||
m_camera->SetProjection(save_proj); | |||
#else | |||
m_meshes[i]->Render(m_mat); | |||
m_meshes[i].m1->Render(m_mat); | |||
#endif //ALL_FEATURES | |||
} | |||
} | |||
@@ -762,19 +818,19 @@ public: | |||
#if 0 //Debug normal draw | |||
for (int i = m_meshes.Count() - 1; 0 <= i && i < m_meshes.Count(); i++) | |||
{ | |||
for (int j = 0; j < m_meshes[i]->m_indices.Count(); j += 3) | |||
for (int j = 0; j < m_meshes[i].m1->m_indices.Count(); j += 3) | |||
{ | |||
VertexData v[3] = { m_meshes[i]->m_vert[m_meshes[i]->m_indices[j ]], | |||
m_meshes[i]->m_vert[m_meshes[i]->m_indices[j+1]], | |||
m_meshes[i]->m_vert[m_meshes[i]->m_indices[j+2]] | |||
VertexData v[3] = { m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j ]], | |||
m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+1]], | |||
m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+2]] | |||
}; | |||
for (int k = 0; k < 3; k++) | |||
Debug::DrawLine((m_mat * mat4::translate(v[k].m_coord)).v3.xyz, | |||
(m_mat * mat4::translate(v[(k+1)%3].m_coord)).v3.xyz, vec4(vec3((v[k].m_coord.z + 1.f)*.5f),1.f)); | |||
} | |||
for (int j = 0; j < m_meshes[i]->m_vert.Count(); j++) | |||
for (int j = 0; j < m_meshes[i].m1->m_vert.Count(); j++) | |||
{ | |||
VertexData &v = m_meshes[i]->m_vert[m_meshes[i]->m_indices[j]]; | |||
VertexData &v = m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j]]; | |||
Debug::DrawLine((m_mat * mat4::translate(v.m_coord)).v3.xyz, | |||
(m_mat * mat4::translate(v.m_coord)).v3.xyz + | |||
(m_mat * vec4(v.m_normal * 5.f, 0.f)).xyz, vec4(lol::abs(v.m_normal), 1.f)); | |||
@@ -813,11 +869,16 @@ private: | |||
vec2 m_hist_scale_speed; | |||
vec2 m_screen_offset; | |||
//Mesh update timer | |||
float m_build_timer; | |||
float m_build_time; | |||
//Mesh infos | |||
vec2 m_render_max; | |||
int m_mesh_render; | |||
int m_mesh_id; | |||
float m_mesh_id1; | |||
Array<EasyMesh*> m_meshes; | |||
Array<EasyMesh*, EasyMesh*> m_meshes; | |||
Array<EasyMesh*> m_gizmos; | |||
//File data | |||