From 9f109ffe304e1bd7b9b0f03c3ff2b7e3a5bfd559 Mon Sep 17 00:00:00 2001 From: NADAL Jean-Baptiste Date: Wed, 28 Feb 2024 10:37:53 +0100 Subject: [PATCH] Fix PVS warning --- apps/chapter_07.cpp | 21 ++++++++++++--------- apps/chapter_09.cpp | 21 ++++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/chapter_07.cpp b/apps/chapter_07.cpp index f256e75..6d639d6 100644 --- a/apps/chapter_07.cpp +++ b/apps/chapter_07.cpp @@ -74,25 +74,28 @@ int main(void) // The large sphere in the middle is a unit sphere, translated upward slightly and colored green. the_middle = new Sphere(); the_middle->set_transform(Matrix::translation(-0.5, 1, 0.5)); - the_middle->material().set_color(Color(0.1, 1, 0.5)); - the_middle->material().set_diffuse(0.7); - the_middle->material().set_specular(0.3); + Material &the_middle_material = the_middle->material(); + the_middle_material.set_color(Color(0.1, 1, 0.5)); + the_middle_material.set_diffuse(0.7); + the_middle_material.set_specular(0.3); the_world.add_object(the_middle); // The smaller green sphere on the right is scaled in half the_right = new Sphere(); the_right->set_transform(Matrix::translation(1.5, 0.5, -0.5) * Matrix::scaling(0.5, 0.5, 0.5)); - the_right->material().set_color(Color(0.5, 1, 0.1)); - the_right->material().set_diffuse(0.7); - the_right->material().set_specular(0.3); + Material &the_right_material = the_right->material(); + the_right_material.set_color(Color(0.5, 1, 0.1)); + the_right_material.set_diffuse(0.7); + the_right_material.set_specular(0.3); the_world.add_object(the_right); // The smallest sphere is scaled by a third, before being translated the_left = new Sphere(); the_left->set_transform(Matrix::translation(-1.5, 0.33, -0.75) * Matrix::scaling(0.33, 0.33, 0.33)); - the_left->material().set_color(Color(1, 0.8, 0.1)); - the_left->material().set_diffuse(0.7); - the_left->material().set_specular(0.3); + Material &the_left_material = the_left->material(); + the_left_material.set_color(Color(1, 0.8, 0.1)); + the_left_material.set_diffuse(0.7); + the_left_material.set_specular(0.3); the_world.add_object(the_left); // The Light source is white, shining from above and to the left diff --git a/apps/chapter_09.cpp b/apps/chapter_09.cpp index c7a05df..b7b6ca4 100644 --- a/apps/chapter_09.cpp +++ b/apps/chapter_09.cpp @@ -58,25 +58,28 @@ int main(void) // The large sphere in the middle is a unit sphere, translated upward slightly and colored green. the_middle = new Sphere(); the_middle->set_transform(Matrix::translation(-0.5, 1, 0.5)); - the_middle->material().set_color(Color(0.1, 1, 0.5)); - the_middle->material().set_diffuse(0.7); - the_middle->material().set_specular(0.3); + Material &the_middle_material = the_middle->material(); + the_middle_material.set_color(Color(0.1, 1, 0.5)); + the_middle_material.set_diffuse(0.7); + the_middle_material.set_specular(0.3); the_world.add_object(the_middle); // The smaller green sphere on the right is scaled in half the_right = new Sphere(); the_right->set_transform(Matrix::translation(1.5, 0.5, -0.5) * Matrix::scaling(0.5, 0.5, 0.5)); - the_right->material().set_color(Color(0.5, 1, 0.1)); - the_right->material().set_diffuse(0.7); - the_right->material().set_specular(0.3); + Material &the_right_material = the_right->material(); + the_right_material.set_color(Color(0.5, 1, 0.1)); + the_right_material.set_diffuse(0.7); + the_right_material.set_specular(0.3); the_world.add_object(the_right); // The smallest sphere is scaled by a third, before being translated the_left = new Sphere(); the_left->set_transform(Matrix::translation(-1.5, 0.33, -0.75) * Matrix::scaling(0.33, 0.33, 0.33)); - the_left->material().set_color(Color(1, 0.8, 0.1)); - the_left->material().set_diffuse(0.7); - the_left->material().set_specular(0.3); + Material &the_left_material = the_left->material(); + the_left_material.set_color(Color(1, 0.8, 0.1)); + the_left_material.set_diffuse(0.7); + the_left_material.set_specular(0.3); the_world.add_object(the_left); // The Light source is white, shining from above and to the left