Correction de probl?me de compilation li? a RayTracing.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 04_RayTracing / moo / host / RayTracing.cu
index 36e3862..5034594 100644 (file)
@@ -8,6 +8,7 @@ using namespace std;
 #include "RayTracing.h"
 #include "Device.h"
 #include "RayTracingDevice.h"
+#include "Sphere.h"
 
 RayTracing::RayTracing(int w, int h)
     : w(w), h(h),
@@ -18,20 +19,18 @@ RayTracing::RayTracing(int w, int h)
     Device::assertDim(dg, db);
 
     const int nbSpheres = 10;
-    Sphere* = this->createSpheres(10);
-
+    Sphere* shperes = this->createSpheres(10);
 
     // Copie les spheres dans la constant memory.
     }
 
 RayTracing::~RayTracing()
     {
-    delete this->ptrDomaineMathInit;
     }
 
-void RayTracing::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)
+void RayTracing::runGPU(uchar4* ptrDevPixels)
     {
-    rayTracing<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, this->t);
+    rayTracing<<<dg,db>>>(ptrDevPixels, this->w, this->h, this->t);
 
     HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).
     }
@@ -61,19 +60,23 @@ string RayTracing::getTitle()
     return this->title;
     }
 
-Sphere* createSpheres(int n)
+Sphere* RayTracing::createSpheres(int n)
     {
     Sphere* spheres = new Sphere[n];
     const float bord = 200;
 
     for (int i = 0; i < n; ++i)
         {
-        spheres[i].setR(float(AleaTools::uniformeAB(20, this->w / 10 - 1)));
-        spheres[i].setCentre(float3 {
-                float(AleaTools::uniformeAB(bord, this->w - bord)),
-                float(AleaTools::uniformeAB(bord, this->h - bord)),
-                float(AleaTools::uniformeAB(10, 2.0 * this->w))
-            });
-        spheres[i].setHue(float(AleaTools::uniformeAB(0, 1))
+        spheres[i].setR(float(this->alea.uniformeAB(20, this->w / 10 - 1)));
+
+        cpu::float3 centre
+            {
+            float(this->alea.uniformeAB(double(bord), double(this->w - bord))),
+            float(this->alea.uniformeAB(double(bord), double(this->h - bord))),
+            float(this->alea.uniformeAB(10.0, 2.0 * this->w))
+            };
+
+        spheres[i].setCentre(centre);
+        spheres[i].setHueInitial(float(this->alea.uniformeAB(0.0, 1.0)));
         }
     }