Esempio n. 1
1
void Block::buildCall(
    Session &session,
    Instance &caller,
    size_t position,
    std::gc_function<void (Block &, Instance &)> &&before,
    std::gc_function<void (Block &, Instance &)> &&after
) {
    // init

    Instance &instance_early {
        *new (GC) Instance
    };

    // render (frame)

    caller.content.insert(
        [&, position](OutputContext &oc) {
            renderFrame(caller, position, oc);
        }
    );

    // in

    before(*this, instance_early);

    // find or create instance

    Instance &instance {
        matchInstance(session, instance_early)
    };

    // render (call)

    caller.content.insert(
        [&, position](OutputContext &oc) {
            renderCall(caller, instance, position, oc);
        }
    );

    // out

    after(*this, instance);
}
void RenderObject::render()
{
	if (isHidden()) return;

	/// new (breaks anything?)
	if (alpha.x == 0 || alphaMod == 0) return;

	if (core->currentLayerPass != RENDER_ALL && renderPass != RENDER_ALL)
	{
		RenderObject *top = getTopParent();
		if (top == NULL && this->overrideRenderPass != OVERRIDE_NONE)
		{
			// FIXME: overrideRenderPass is not applied to the
			// node itself in the original check (below); is
			// that intentional?  Doing the same thing here
			// for the time being.  --achurch
			if (core->currentLayerPass != this->renderPass
			 && core->currentLayerPass != this->overrideRenderPass)
				return;
		}
		else if (top != NULL && top->overrideRenderPass != OVERRIDE_NONE)
		{
			if (core->currentLayerPass != top->overrideRenderPass)
				return;
		}
		else
		{
			if (!hasRenderPass(core->currentLayerPass))
				return;
		}
	}
	
	if (motionBlur || motionBlurTransition)
	{
		Vector oldPos = position;
		float oldAlpha = alpha.x;
		float oldRotZ = rotation.z;
		for (int i = 0; i < motionBlurPositions.size(); i++)
		{
			position = motionBlurPositions[i].position;
			rotation.z = motionBlurPositions[i].rotz;
			alpha = 1.0f-(float(i)/float(motionBlurPositions.size()));
			alpha *= 0.5f;
			if (motionBlurTransition)
			{
				alpha *= motionBlurTransitionTimer;
			}
			renderCall();
		}		
		position = oldPos;
		alpha.x = oldAlpha;
		rotation.z = oldRotZ;

		renderCall();
	}
	else
		renderCall();
}