Text archives Help
- From: roni@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r2158 - in trunk: Engine/Renderers Model/Instances
- Date: Sun, 30 Mar 2008 21:59:24 -0600 (MDT)
Author: roni
Date: Sun Mar 30 21:59:23 2008
New Revision: 2158
Modified:
trunk/Engine/Renderers/NPREdges.cc
trunk/Engine/Renderers/NPREdges.h
trunk/Model/Instances/Instance.cc
trunk/Model/Instances/Instance.h
Log:
Instance.{cc|h}:
Added a const version of getObject();
NPREdge.{cc|h}:
Added function to detect whether a primitive is known to have crease
edges or not. Need to figure out if this is terrible for
performance.
Modified: trunk/Engine/Renderers/NPREdges.cc
==============================================================================
--- trunk/Engine/Renderers/NPREdges.cc (original)
+++ trunk/Engine/Renderers/NPREdges.cc Sun Mar 30 21:59:23 2008
@@ -12,6 +12,7 @@
#include <Model/Primitives/Cube.h>
#include <Model/Primitives/QuadFacedHexahedron.h>
#include <Model/Primitives/ValuePrimitive.h>
+#include <Model/Instances/Instance.h>
#include <iostream>
using namespace std;
@@ -229,24 +230,9 @@
normDown.computeFFNormals(context);
for(int k=i; k<j; k++){
- // TODO(choudhury): check if the primitive is an instance of
- // one of the creased-primitive types.
const Primitive *hitprim = rays.getHitPrimitive(k);
-
- if(typeid(*hitprim) == typeid(ValuePrimitive<double>)){
- const Primitive *prim = dynamic_cast<const
ValuePrimitive<double> *>(hitprim)->getPrimitive();
- if(!(typeid(*prim) == typeid(Cube) ||
- typeid(*prim) == typeid(QuadFacedHexahedron))){
-
- //std::cout << "ValuePrimitive: " << typeid(*prim).name() <<
std::endl;
- continue;
- }
- }
- else if(!(typeid(*hitprim) == typeid(Cube) ||
- typeid(*hitprim) == typeid(QuadFacedHexahedron))){
- //std::cout << "Regular Primitive: " << typeid(*hitprim).name()
<< std::endl;
+ if(!creasable(hitprim))
continue;
- }
// Compute the gradient of the normal field.
const Vector v1 = normRight.getFFNormal(k) -
normLeft.getFFNormal(k);
@@ -336,6 +322,26 @@
// If we reach here, the sample ray struck a primitive, and so did
// all the stencil rays.
return Shade;
+}
+
+bool NPREdges::creasable(const Primitive *prim){
+ if(dynamic_cast<const ValuePrimitive<double> *>(prim)){
+ return creasable(dynamic_cast<const ValuePrimitive<double>
*>(prim)->getPrimitive());
+ }
+ else if(dynamic_cast<const Instance *>(prim)){
+ const Object *inst = dynamic_cast<const Instance *>(prim)->getInstance();
+ const Primitive *p = dynamic_cast<const Primitive *>(inst);
+ if(!p){
+ return false;
+ }
+ else{
+ return creasable(p);
+ }
+ }
+ else{
+ return (dynamic_cast<const Cube *>(prim) ||
+ dynamic_cast<const QuadFacedHexahedron *>(prim));
+ }
}
void NPREdges::setNormalThreshold(Real val){
Modified: trunk/Engine/Renderers/NPREdges.h
==============================================================================
--- trunk/Engine/Renderers/NPREdges.h (original)
+++ trunk/Engine/Renderers/NPREdges.h Sun Mar 30 21:59:23 2008
@@ -9,6 +9,7 @@
using namespace Manta;
namespace Manta {
+ class Primitive;
class Raytracer;
using namespace std;
@@ -39,6 +40,8 @@
PixelType type(const RayPacket& sample, const RayPacket *stencil, int i)
const;
PixelType type(const RayPacket& sample, const RayPacket *stencil, int i,
int& count) const;
+
+ static bool creasable(const Primitive *prim);
Raytracer *raytracer;
Modified: trunk/Model/Instances/Instance.cc
==============================================================================
--- trunk/Model/Instances/Instance.cc (original)
+++ trunk/Model/Instances/Instance.cc Sun Mar 30 21:59:23 2008
@@ -120,6 +120,10 @@
return instance;
}
+const Object* Instance::getInstance() const {
+ return instance;
+}
+
void Instance::preprocess(const PreprocessContext& context)
{
//cerr << MANTA_FUNC << endl;
Modified: trunk/Model/Instances/Instance.h
==============================================================================
--- trunk/Model/Instances/Instance.h (original)
+++ trunk/Model/Instances/Instance.h Sun Mar 30 21:59:23 2008
@@ -51,6 +51,7 @@
void setTransform(AffineTransform new_transform);
Object* getInstance();
+ const Object *getInstance() const;
// Generic
virtual void preprocess(const PreprocessContext&);
- [Manta] r2158 - in trunk: Engine/Renderers Model/Instances, roni, 03/30/2008
Archive powered by MHonArc 2.6.16.