Browse Source

Scene::AddPrimitive now only supports Primitive because why not

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 9 years ago
parent
commit
22322d50fd
7 changed files with 18 additions and 21 deletions
  1. +7
    -7
      doc/samples/meshviewer/meshviewer.cpp
  2. +2
    -2
      doc/samples/physicobject.h
  3. +1
    -1
      doc/tutorial/05_easymesh.cpp
  4. +6
    -0
      src/mesh/mesh.cpp
  5. +2
    -0
      src/mesh/mesh.h
  6. +0
    -10
      src/scene.cpp
  7. +0
    -1
      src/scene.h

+ 7
- 7
doc/samples/meshviewer/meshviewer.cpp View File

@@ -101,7 +101,7 @@ void EasyMeshViewerObject::TickDraw(float seconds, Scene &scene)
switch (m_mesh.GetMeshState().ToScalar())
{
case MeshRender::NeedConvert: { m_mesh.MeshConvert(); break; }
case MeshRender::CanRender: { scene.AddPrimitive(m_mesh, mat4::identity/*TODO:FIX THAT*/); break; }
case MeshRender::CanRender: { m_mesh.Render(scene, mat4::identity/*TODO:FIX THAT*/); break; }
default: break;
}
}
@@ -1030,12 +1030,12 @@ void MeshViewer::Draw(float seconds, Scene &scene)
//Camera projection
mat4 new_proj = mat_obj_offset * mat_count_offset * mat_align * mat_count_scale * save_proj;
m_camera->SetProjection(new_proj);
scene.AddPrimitive(*m_meshes[i].m1, m_mat);
m_meshes[i].m1->Render(scene, m_mat);
g_renderer->Clear(ClearMask::Depth);
}
m_camera->SetProjection(save_proj);
#else
scene.AddPrimitive(*m_meshes[i].m1, m_mat);
m_meshes[i].m1->Render(scene, m_mat);
#endif //ALL_FEATURES
}
}
@@ -1045,7 +1045,7 @@ void MeshViewer::Draw(float seconds, Scene &scene)
{
m_camera->SetProjection(mat_gizmo);
if (m_ssetup->m_show_gizmo)
scene.AddPrimitive(*m_gizmos[GZ_Editor], m_mat);
m_gizmos[GZ_Editor]->Render(scene, m_mat);

if (m_ssetup->m_show_lights)
{
@@ -1057,12 +1057,12 @@ void MeshViewer::Draw(float seconds, Scene &scene)
//dir light
if (ltmp->GetType() == LightType::Directional)
{
scene.AddPrimitive(*m_gizmos[GZ_LightPos], m_mat * inverse(local));
scene.AddPrimitive(*m_gizmos[GZ_LightDir], inverse(world) * inverse(mat4::lookat(vec3::zero, -ltmp->GetPosition(), vec3::axis_y)));
m_gizmos[GZ_LightPos]->Render(scene, m_mat * inverse(local));
m_gizmos[GZ_LightDir]->Render(scene, inverse(world) * inverse(mat4::lookat(vec3::zero, -ltmp->GetPosition(), vec3::axis_y)));
}
else //point light
{
scene.AddPrimitive(*m_gizmos[GZ_LightPos], m_mat * local);
m_gizmos[GZ_LightPos]->Render(scene, m_mat * local);
}
}
}


+ 2
- 2
doc/samples/physicobject.h View File

@@ -334,9 +334,9 @@ protected:
else if (m_should_render)
{
if (m_is_character)
scene.AddPrimitive(m_mesh, m_character->GetTransform());
m_mesh.Render(scene, m_character->GetTransform());
else
scene.AddPrimitive(m_mesh, m_physics->GetTransform());
m_mesh.Render(scene, m_physics->GetTransform());
}
}
}


+ 1
- 1
doc/tutorial/05_easymesh.cpp View File

@@ -146,7 +146,7 @@ public:

for (int i = 0; i < m_gears.Count(); i++)
{
scene.AddPrimitive(m_gears[i].m1, m_mat * m_gears[i].m2);
m_gears[i].m1.Render(scene, m_mat * m_gears[i].m2);
}
}



+ 6
- 0
src/mesh/mesh.cpp View File

@@ -28,6 +28,12 @@ Mesh::~Mesh()
{
}

void Mesh::Render(Scene& scene, mat4 const &matrix)
{
for (int i = 0; i < m_submeshes.Count(); ++i)
scene.AddPrimitive(new PrimitiveMesh(m_submeshes[i], matrix));
}

void Mesh::Render()
{
for (int i = 0; i < m_submeshes.Count(); ++i)


+ 2
- 0
src/mesh/mesh.h View File

@@ -59,6 +59,8 @@ public:
* may behave differently between submeshes. */
void SetMaterial(Shader *shader);

//TODO: Not sure about the name
void Render(Scene& scene, mat4 const &matrix);
protected:
void Render();



+ 0
- 10
src/scene.cpp View File

@@ -254,16 +254,6 @@ void Scene::Reset()
data->m_primitives.Empty();
}

//-----------------------------------------------------------------------------
/*TODO: SAM/TOUKY: Change that*/
void Scene::AddPrimitive(Mesh const &mesh, mat4 const &matrix)
{
for (int i = 0; i < mesh.m_submeshes.Count(); ++i)
{
AddPrimitive(new PrimitiveMesh(mesh.m_submeshes[i], matrix));
}
}

//-----------------------------------------------------------------------------
void Scene::AddPrimitive(Primitive* primitive)
{


+ 0
- 1
src/scene.h View File

@@ -93,7 +93,6 @@ public:
void Reset();

/* New scenegraph */
void AddPrimitive(Mesh const &mesh, mat4 const &matrix);
void AddPrimitive(Primitive* primitive);
void AddPrimitive(Entity* entity, Primitive* primitive);



Loading…
Cancel
Save