Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1301 - trunk/Engine/Shadows
- Date: Wed, 14 Mar 2007 15:08:45 -0700 (MST)
Author: sparker
Date: Wed Mar 14 15:08:44 2007
New Revision: 1301
Modified:
trunk/Engine/Shadows/HardShadows.cc
trunk/Engine/Shadows/HardShadows.h
trunk/Engine/Shadows/NoShadows.cc
trunk/Engine/Shadows/NoShadows.h
Log:
Improve interface to shadow algorithm
Modified: trunk/Engine/Shadows/HardShadows.cc
==============================================================================
--- trunk/Engine/Shadows/HardShadows.cc (original)
+++ trunk/Engine/Shadows/HardShadows.cc Wed Mar 14 15:08:44 2007
@@ -28,12 +28,11 @@
{
}
-bool HardShadows::computeShadows(const RenderContext& context,
+void HardShadows::computeShadows(const RenderContext& context,
+ StateBuffer& stateBuffer,
const LightSet* lights,
RayPacket& sourceRays, // Input rays.
- RayPacket& shadowRays, // Output
shadow rays, already intersected.
- bool firstTime,
- StateBuffer& stateBuffer)
+ RayPacket& shadowRays) // Output
shadow rays, already intersected.
{
int nlights = lights->numLights();
@@ -42,9 +41,12 @@
sourceRays.computeFFNormals( context );
int j;
- if(firstTime){
+ if(stateBuffer.state == StateBuffer::Finished){
+ return; // Shouldn't happen, but just in case...
+ } else if(stateBuffer.state == StateBuffer::Start){
j = 0;
} else {
+ // Continuing
j = stateBuffer.i1;
}
@@ -171,13 +173,19 @@
j++;
} while(last == -1 && j < nlights);
- // Send the shadow rays.
- shadowRays.setFlag( RayPacket::NormalizedDirections );
- shadowRays.resize ( last + 1);
- context.scene->getObject()->intersect(context, shadowRays);
+ // Send the shadow rays, if any
+ if(last != -1){
+ shadowRays.setFlag( RayPacket::NormalizedDirections );
+ shadowRays.resize ( last + 1);
+ context.scene->getObject()->intersect(context, shadowRays);
+ }
- stateBuffer.i1 = j;
- return j == nlights;
+ if(j == nlights){
+ stateBuffer.state = StateBuffer::Finished;
+ } else {
+ stateBuffer.state = StateBuffer::Continuing;
+ stateBuffer.i1 = j;
+ }
}
string HardShadows::getName() const {
Modified: trunk/Engine/Shadows/HardShadows.h
==============================================================================
--- trunk/Engine/Shadows/HardShadows.h (original)
+++ trunk/Engine/Shadows/HardShadows.h Wed Mar 14 15:08:44 2007
@@ -16,9 +16,8 @@
HardShadows(const vector<string>& args);
virtual ~HardShadows();
- virtual bool computeShadows(const RenderContext& context, const
LightSet* lights,
- RayPacket& source, RayPacket& shadowRays,
- bool firstTime, StateBuffer& stateBuffer);
+ virtual void computeShadows(const RenderContext& context, StateBuffer&
stateBuffer,
+ const LightSet* lights, RayPacket& source,
RayPacket& shadowRays);
static ShadowAlgorithm* create(const vector<string>& args);
Modified: trunk/Engine/Shadows/NoShadows.cc
==============================================================================
--- trunk/Engine/Shadows/NoShadows.cc (original)
+++ trunk/Engine/Shadows/NoShadows.cc Wed Mar 14 15:08:44 2007
@@ -19,9 +19,8 @@
{
}
-bool NoShadows::computeShadows(const RenderContext& context, const LightSet*
lights,
- RayPacket& sourceRays, RayPacket& shadowRays,
- bool firstTime, StateBuffer& stateBuffer)
+void NoShadows::computeShadows(const RenderContext& context, StateBuffer&
stateBuffer,
+ const LightSet* lights, RayPacket&
sourceRays, RayPacket& shadowRays)
{
int nlights = lights->numLights();
@@ -30,11 +29,15 @@
sourceRays.computeFFNormals( context );
int j;
- if(firstTime){
+ if(stateBuffer.state == StateBuffer::Finished){
+ return; // Shouldn't happen, but just in case...
+ } else if(stateBuffer.state == StateBuffer::Start){
j = 0;
} else {
+ // Continuing
j = stateBuffer.i1;
}
+
// Compute the contribution for this light.
int last = -1;
do {
@@ -59,8 +62,13 @@
j++;
} while(last == -1 && j < nlights);
shadowRays.resize (last+1);
- stateBuffer.i1 = j;
- return j == nlights;
+
+ if(j == nlights){
+ stateBuffer.state = StateBuffer::Finished;
+ } else {
+ stateBuffer.state = StateBuffer::Continuing;
+ stateBuffer.i1 = j;
+ }
}
string NoShadows::getName() const {
Modified: trunk/Engine/Shadows/NoShadows.h
==============================================================================
--- trunk/Engine/Shadows/NoShadows.h (original)
+++ trunk/Engine/Shadows/NoShadows.h Wed Mar 14 15:08:44 2007
@@ -15,9 +15,8 @@
NoShadows(const vector<string>& args);
virtual ~NoShadows();
- virtual bool computeShadows(const RenderContext& context, const
LightSet* lights,
- RayPacket& source, RayPacket& shadowRays,
- bool firstTime, StateBuffer& stateBuffer);
+ virtual void computeShadows(const RenderContext& context, StateBuffer&
stateBuffer,
+ const LightSet* lights, RayPacket& source,
RayPacket& shadowRays);
static ShadowAlgorithm* create(const vector<string>& args);
- [MANTA] r1301 - trunk/Engine/Shadows, sparker, 03/14/2007
Archive powered by MHonArc 2.6.16.