Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2035 - in trunk: Core/Geometry Core/Persistent Model/Groups StandAlone


Chronological Thread 
  • From: "Solomon Boulos" <boulos@cs.utah.edu>
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2035 - in trunk: Core/Geometry Core/Persistent Model/Groups StandAlone
  • Date: Tue, 5 Feb 2008 21:32:22 -0700 (MST)

Author: boulos
Date: Tue Feb  5 21:32:20 2008
New Revision: 2035

Modified:
   trunk/Core/Geometry/BBox.cc
   trunk/Core/Geometry/BBox.h
   trunk/Core/Persistent/MantaRTTI.h
   trunk/Core/Persistent/stdRTTI.h
   trunk/Model/Groups/DynBVH.cc
   trunk/Model/Groups/DynBVH.h
   trunk/StandAlone/savescene.cc
Log:
Core/Geometry/BBox.cc
Core/Geometry/BBox.h

 Adding serialization of BBox.

Core/Persistent/MantaRTTI.h
Core/Persistent/stdRTTI.h

 Adding support for writing ints directly (used by BVH)

 Trying to flesh out the vector<T> implementation. Unfortunately,
 writing a vector complains about using the same name for the field.

Model/Groups/DynBVH.cc
Model/Groups/DynBVH.h

 DynBVH is a subclass of AccelerationStructure not Group.

 Add support for serialization of BVHNodes, but try to avoid SWIG
 correctly (using ifndef SWIG)

 Not storing the group pointer yet since that currently uses ObjGroup
 or some other such data structure.

StandAlone/savescene.cc

 Adding some code to kick off the preprocess so that BVHs get built,
 etc.

 I think BVH serialization is pretty close.


Modified: trunk/Core/Geometry/BBox.cc
==============================================================================
--- trunk/Core/Geometry/BBox.cc (original)
+++ trunk/Core/Geometry/BBox.cc Tue Feb  5 21:32:20 2008
@@ -1,10 +1,16 @@
 #include <iostream>
 #include <Core/Geometry/BBox.h>
+#include <Core/Persistent/ArchiveElement.h>
 using namespace Manta;
 
 namespace Manta {
   std::ostream& operator<< (std::ostream& os, const BBox& bounds) {
     os << bounds.getMin() << " " << bounds.getMax();
     return os;
+  }
+
+  void BBox::readwrite(ArchiveElement* archive) {
+    archive->readwrite("min", bounds[0]);
+    archive->readwrite("max", bounds[1]);
   }
 }

Modified: trunk/Core/Geometry/BBox.h
==============================================================================
--- trunk/Core/Geometry/BBox.h  (original)
+++ trunk/Core/Geometry/BBox.h  Tue Feb  5 21:32:20 2008
@@ -4,6 +4,7 @@
 
 #include <Core/Geometry/Vector.h>
 #include <Core/Math/Expon.h>
+#include <Core/Persistent/MantaRTTI.h>
 #include <limits>
 #include <iosfwd>
 
@@ -130,12 +131,16 @@
     inline const Vector &operator[] (int i) const { return bounds[i]; }
 #endif
 
+    void readwrite(ArchiveElement*);
+
   private:
     Vector bounds[2];
   };
 
   // Outside the class but in Manta namespace
   std::ostream& operator<< (std::ostream& os, const BBox& v);
+
+  MANTA_DECLARE_RTTI_BASECLASS(BBox, ConcreteClass, 
readwriteMethod_lightweight);
 }
 
 #endif

Modified: trunk/Core/Persistent/MantaRTTI.h
==============================================================================
--- trunk/Core/Persistent/MantaRTTI.h   (original)
+++ trunk/Core/Persistent/MantaRTTI.h   Tue Feb  5 21:32:20 2008
@@ -44,7 +44,7 @@
    *  // Recursively serialize/deserialize the object into the given
    *  // record
    *  void readwrite(ArchiveElement*, T&);
-   * 
+   *
    * These methods can often be provided by the default classes below
    * that provide standard implementations by making the
    * specialization inherit from the default implementation class.
@@ -89,7 +89,7 @@
   class PointerWrapperInterface {
   public:
     virtual ~PointerWrapperInterface();
-    
+
     virtual bool isNull() const = 0;
     virtual void setNull() = 0;
     virtual bool upcast(PointerWrapperInterface* destination) = 0;
@@ -119,7 +119,7 @@
   template<class T>
   class PointerWrapper : public PointerWrapperInterface {
   public:
-    PointerWrapper(T* ptr, const ClassRTTIInterface<T>* rtti) 
+    PointerWrapper(T* ptr, const ClassRTTIInterface<T>* rtti)
       : ptr(ptr), rtti(rtti) {
     }
     virtual ~PointerWrapper() {}
@@ -460,6 +460,14 @@
   public:
     static std::string getPublicClassname() {
       return "double";
+    }
+  };
+
+  template<>
+  class MantaRTTI<int> {
+  public:
+    static std::string getPublicClassname() {
+      return "int";
     }
   };
 }

Modified: trunk/Core/Persistent/stdRTTI.h
==============================================================================
--- trunk/Core/Persistent/stdRTTI.h     (original)
+++ trunk/Core/Persistent/stdRTTI.h     Tue Feb  5 21:32:20 2008
@@ -9,7 +9,7 @@
 
 namespace Manta {
   template<class T>
-    class MantaRTTI<std::vector<T> > : public 
MantaRTTI_BaseClass<std::vector<T*> > {
+    class MantaRTTI<std::vector<T> > : public 
MantaRTTI_BaseClass<std::vector<T> > {
   public:
     static std::string getPublicClassname() {
       init.forceinit();
@@ -21,7 +21,20 @@
     }
     static void readwrite(ArchiveElement* archive, std::vector<T>& data) {
       init.forceinit();
-      NOT_FINISHED("vector readwrite");
+      if(archive->reading()){
+        data.resize(0);
+        while(archive->nextContainerElement()){
+          T val;
+          data.push_back(val);
+          archive->readwrite("element", data.back());
+        }
+      } else {
+        for(typename std::vector<T>::iterator iter = data.begin(); iter != 
data.end(); iter++)
+          archive->readwrite("element", *iter);
+      }
+    }
+    static PersistentStorage::StorageHint storageHint() {
+      return PersistentStorage::Container;
     }
   private:
     class Initializer {

Modified: trunk/Model/Groups/DynBVH.cc
==============================================================================
--- trunk/Model/Groups/DynBVH.cc        (original)
+++ trunk/Model/Groups/DynBVH.cc        Tue Feb  5 21:32:20 2008
@@ -4,6 +4,7 @@
 #include <Core/Util/UpdateGraph.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <Core/Persistent/MantaRTTI.h>
+#include <Core/Persistent/stdRTTI.h>
 #include <DynBVH_Parameters.h>
 #include <Interface/Context.h>
 #include <Interface/Task.h>
@@ -1696,14 +1697,29 @@
 #endif // MANTA_SSE for USE_DYNBVH_PORTS
 
 namespace Manta {
-  //MANTA_DECLARE_RTTI_DERIVEDCLASS(DynBVH, Group, ConcreteClass, 
readwriteMethod);
-  //MANTA_REGISTER_CLASS(DynBVH);
+  MANTA_DECLARE_RTTI_DERIVEDCLASS(DynBVH, AccelerationStructure, 
ConcreteClass, readwriteMethod);
+  MANTA_REGISTER_CLASS(DynBVH);
+
+#ifndef SWIG
+  MANTA_DECLARE_RTTI_BASECLASS(DynBVH::BVHNode, ConcreteClass, 
readwriteMethod);
+  MANTA_REGISTER_CLASS(DynBVH::BVHNode);
+#endif
 }
 
-void DynBVH::readwrite(ArchiveElement* archive)
-{
-  // TODO(boulos): Fix this...
-  //MantaRTTI<Group>::readwrite(archive, *this);
-  //archive->readwrite("object_ids", object_ids);
+#ifndef SWIG
+void DynBVH::BVHNode::readwrite(ArchiveElement* archive) {
+  archive->readwrite("bounds", bounds);
+  archive->readwrite("child", child);
+  archive->readwrite("axis", axis);
+  archive->readwrite("axis_sign", axis_sign);
+  archive->readwrite("children", children);
+}
+#endif
+
+void DynBVH::readwrite(ArchiveElement* archive) {
+  //archive->readwrite("group", currGroup);
+  archive->readwrite("object_ids", object_ids);
+  archive->readwrite("nodes", nodes);
+  archive->readwrite("num_nodes", num_nodes);
 }
 

Modified: trunk/Model/Groups/DynBVH.h
==============================================================================
--- trunk/Model/Groups/DynBVH.h (original)
+++ trunk/Model/Groups/DynBVH.h Tue Feb  5 21:32:20 2008
@@ -24,9 +24,10 @@
       Real min_org_rcp[3];
       Real max_org_rcp[3];
     };
-  protected:
+
     struct BVHNode
     {
+    public:
       BBox bounds;
       int child; // my child
       unsigned char axis; // 0 = x, 1 = y, 2 = z,
@@ -56,8 +57,10 @@
         return children != 0;
       }
 
+      void readwrite(ArchiveElement* archive);
     };
 
+  protected:
     vector<BVHNode> nodes;
     vector<int> object_ids;
     unsigned int num_nodes;
@@ -80,7 +83,9 @@
     bool print_info;
 
   public:
-    DynBVH(bool print = true) : currGroup(NULL), group_changed(false), 
barrier("DynBVH barrier"), print_info(print)
+    //DynBVH() : currGroup(NULL), group_changed(false), barrier("DynBVH 
barrier"), print_info(false) {
+    //}
+    DynBVH(bool print=false) : currGroup(NULL), group_changed(false), 
barrier("DynBVH barrier"), print_info(print)
     {}
 
     void setGroup(Group* new_group);

Modified: trunk/StandAlone/savescene.cc
==============================================================================
--- trunk/StandAlone/savescene.cc       (original)
+++ trunk/StandAlone/savescene.cc       Tue Feb  5 21:32:20 2008
@@ -33,12 +33,17 @@
 #include <Core/Persistent/Archive.h>
 #include <Core/Persistent/ArchiveElement.h>
 #include <Engine/Factory/Factory.h>
+#include <Interface/Context.h>
 #include <Interface/MantaInterface.h>
 #include <Interface/InterfaceRTTI.h>
 #include <Interface/Scene.h>
 #include <Core/Thread/Thread.h>
+#include <Core/Util/Assert.h>
 #include <Model/Textures/CheckerTexture.h>
 
+#include <Interface/Background.h>
+#include <Interface/LightSet.h>
+
 #include <iostream>
 #include <string>
 
@@ -51,6 +56,18 @@
   exit(1);
 }
 
+void rtrtPreprocess(MantaInterface* rtrt,
+                    Scene* scene) {
+  LightSet* lights = scene->getLights();
+
+  PreprocessContext context(rtrt, 0, 1, lights);
+  lights->preprocess(context);
+  scene->getBackground()->preprocess(context);
+
+  //cerr << "About to preprocess the scene (proc " << proc << ")...\n";
+  scene->getObject()->preprocess(context);
+}
+
 int
 main(int argc, char* argv[])
 {
@@ -58,7 +75,7 @@
   vector<string> args;
   for(int i=1;i<argc;i++)
     args.push_back(argv[i]);
-       
+
   try {
 
     
///////////////////////////////////////////////////////////////////////////
@@ -67,7 +84,7 @@
 
     // Create a Manta Factory.
     Factory* factory = new Factory( rtrt );
-    
+
     // Set the scene search path based on an env variable.
     if(getenv("MANTA_SCENEPATH"))
       factory->setScenePath(getenv("MANTA_SCENEPATH"));
@@ -87,11 +104,12 @@
     string outfile;
     if(!getStringArg(i, args, outfile))
       usage();
-    
+
     Archive* archive = Archive::openForWriting(outfile);
     if(!archive)
       throw OutputError("Could not open Archive for writing: " + outfile);
     Scene* scene = rtrt->getScene();
+    rtrtPreprocess(rtrt, scene);
     ArchiveElement* root = archive->getRoot();
     root->readwrite("scene", scene);
     delete archive;
@@ -100,13 +118,13 @@
   } catch (Exception& e) {
     cerr << "savescene.cc (top level): Caught exception: " << e.message() << 
'\n';
     Thread::exitAll( 1 );
-               
+
   } catch (std::exception e){
     cerr << "savescene.cc (top level): Caught std exception: "
          << e.what()
          << '\n';
     Thread::exitAll(1);
-               
+
   } catch(...){
     cerr << "savescene.cc (top level): Caught unknown exception\n";
     Thread::exitAll(1);




  • [Manta] r2035 - in trunk: Core/Geometry Core/Persistent Model/Groups StandAlone, Solomon Boulos, 02/05/2008

Archive powered by MHonArc 2.6.16.

Top of page