Exemplo n.º 1
0
   State &operator= (const State &Value) {

      cache = 0;

      if (Value.context && (Value.context != context)) {

         if (context) { context->unref (); context = 0; }

         context = Value.context;

         if (context) { context->ref (); }
      }

      dataTable.empty ();
      dataTable.copy (Value.dataTable);

      if (Value.stringTable) {

         if (!stringTable) { stringTable = new stringStruct; }
         if (stringTable) { *stringTable = *(Value.stringTable); }
      }
      else if (stringTable) { delete stringTable; stringTable = 0; }

      return *this;
   };
Exemplo n.º 2
0
/*!

\brief PluginInfo constructor.
\param[in] Info PluginInfo used to obtain the runtime context.

*/
dmz::Undo::Undo (const PluginInfo &Info) : _context (0) {

    RuntimeContext *context (Info.get_context ());
    if (context) {
        _context = context->get_undo_context();
    }
    if (_context) {
        _context->ref ();
    }
}
Exemplo n.º 3
0
   State (RuntimeContext *theContext, Log *theLog) :
         context (theContext),
         defs (0),
         log (theLog) {

      if (context) {

         context->ref ();
         defs = context->get_definitions_context ();
         if (defs) { defs->ref (); }
      }
   }
   State (PluginInfo &theInfo, Log *theLog) :
         Plugin (theInfo),
         RuntimeModule (theInfo),
         MessageObserver (theInfo),
         observerContext (0),
         convert (theInfo),
         info (theInfo),
         discovered (False),
         started (False),
         levelsHead (0),
         levelsTail (0),
         maxLevel (1),
         log (theLog) {

      externTable.store (get_plugin_handle (), this);

      RuntimeContext *rt = info.get_context ();

      if (rt) {

         observerContext = rt->get_plugin_observer_context ();

         Definitions defs (rt);

         Message msg;

         defs.create_message (PluginObserverActivateMessageName, msg);

         subscribe_to_message (msg);
      }

      if (observerContext) {

         observerContext->ref ();
         observerContext->moduleTable.store (info.get_handle (), this);
      }
   }
Exemplo n.º 5
0
   ~State () {

      levelTable.clear ();

      if (_handlePtr) { delete _handlePtr; _handlePtr = 0; }
      else {

         Definitions defs (context);
         defs.release_unique_name (Name);
      }

      if (context) { context->unref (); context = 0; }

      if (lib) { delete lib; lib = 0; }
   }
Exemplo n.º 6
0
   State (
         const String &TheName,
         const String &TheClassName,
         const String &TheFactoryName,
         const String &TheScopeName,
         const PluginDeleteModeEnum TheDeleteMode,
         RuntimeContext *theContext,
         DynamicLibrary *theLib) :
         _handlePtr (TheName ? 0 : new RuntimeHandle ("Plugin", theContext)),
         Name (TheName ? TheName : "Unnamed Component"),
         ClassName (TheClassName),
         FactoryName (TheFactoryName),
         ScopeName (TheScopeName),
         PluginHandle (_handlePtr ?
            _handlePtr->get_runtime_handle () :
            Definitions (theContext).create_named_handle (TheName)),
         deleteMode (TheDeleteMode),
         context (theContext),
         lib (theLib) {

      if (context) { context->ref (); }
   }
Exemplo n.º 7
0
/*!

\brief PluginInfo Constructor.
\param[in] Info Reference to the PluginInfo.
\param[in] log Pointer to the Log to user for error reporting.

*/
dmz::Resources::Resources (const PluginInfo &Info, Log *log) : _context (0), _log (log) {

   RuntimeContext *context (Info.get_context ());
   _context = (context ? context->get_resources_context () : 0);
   if (_context) { _context->ref (); }
}
Exemplo n.º 8
0
   ~State () {

      if (defs) { defs->unref (); defs = 0; }
      if (context) { context->unref (); context = 0; }
      log = 0;
   }
Exemplo n.º 9
0
//! Tells the shader to apply shade to the given intersection point
void AreaLightShaderOp::PerformOperation(
	const RuntimeContext& rc,					///< [in] Runtime context
	const RayIntersection& ri,					///< [in] Intersection information 
	const IRayCaster& caster,					///< [in] The Ray Caster to use for all ray casting needs
	const IRayCaster::RAY_STATE& rs,			///< [in] Current ray state
	RISEPel& c,									///< [in/out] Resultant color from op
	const IORStack* const ior_stack,			///< [in/out] Index of refraction stack
	const ScatteredRayContainer* pScat			///< [in] Scattering information
	) const
{
	c = RISEPel(0.0);

	// Only do stuff on a normal pass or on final gather
	if( rc.pass != RuntimeContext::PASS_NORMAL && rs.type == rs.eRayView ) {
		return;
	}

	const IBSDF* pBRDF = ri.pMaterial ? ri.pMaterial->GetBSDF() : 0;

	// Lets check our rasterizer state to see if we even need to do work!
	if( cache ) {
		if( !rc.StateCache_HasStateChanged( this, c, ri.pObject, ri.geometric.rast ) ) {
			// State hasn't changed, use the value already there
			return;
		}
	}

	ISampling2D::SamplesList2D samples;
	pSampler->GenerateSamplePoints( rc.random, samples );

	{
		ISampling2D::SamplesList2D::iterator m, n;
		for( m=samples.begin(), n=samples.end(); m!=n; m++ ) {
			*m = Point2Ops::mkPoint2(*m, Vector2( -width/2, -height/2 ));
		}
	}

	const RISEPel pN = N.GetColor( ri.geometric );

	for( ISampling2D::SamplesList2D::const_iterator it = samples.begin(); it != samples.end(); it++ ) {
		const Point2& sample = *it;

		// Construct a random sample in R^3
		const Point3 ptOnLight = Point3Ops::mkPoint3( location, Vector3Ops::Transform( mxtransform, Vector3( sample.x, 0, sample.y ) ) );

		// Now then we do the usual lighting test for this sample point
		Vector3				vToLight = Vector3Ops::mkVector3( ptOnLight, ri.geometric.ptIntersection );
		const Scalar		fDistFromLight = Vector3Ops::NormalizeMag(vToLight);	
		const Scalar		fDot = Vector3Ops::Dot( vToLight, ri.geometric.vNormal );

		const Vector3		vFromLight = -vToLight;
		const Scalar		fDotLight = Vector3Ops::Dot( vFromLight, dir );

		if( fDotLight < 0 ) {
			continue;
		}

		if( fDot < 0 ) {
			continue;
		}

		const Scalar fAngleOfIncidence = acos(fDot);

		if( fAngleOfIncidence <= hotSpot/2.0 ) {
			// Check to see if there is a shadow
			if( ri.pObject->DoesReceiveShadows() ) {
				const Ray		rayToLight( ri.geometric.ptIntersection, vToLight );
				if( caster.CastShadowRay( rayToLight, fDistFromLight ) ) {
					continue;
				}
			}		

			const RISEPel	k = (pN + 1) * pow(fDot,pN) * (1.0 / TWO_PI);
			const Scalar	attenuation_size_factor = area / (fDistFromLight * fDistFromLight);
			c = c + (emm.GetColor(ri.geometric) * k * power * fDotLight * attenuation_size_factor * (pBRDF?pBRDF->value(vToLight,ri.geometric):RISEPel(1,1,1)));
		}
	}

	c = c * (1.0/samples.size());

	// Add the result to the rasterizer state cache
	if( cache ) {
		rc.StateCache_SetState( this, c, ri.pObject, ri.geometric.rast );
	}
}
Exemplo n.º 10
0
 ~State () { empty (); if (context) { context->unref (); } }
Exemplo n.º 11
0
 State (RuntimeContext *theContext) :
       context (theContext),
       cache (0),
       stringTable (0) { if (context) { context->ref (); } }