Ejemplo n.º 1
0
void C4MeshDenumerator::CompileFunc(StdCompiler* pComp, StdMeshInstance::AttachedMesh* attach)
{
	if(pComp->isDeserializer())
	{
		int32_t def;
		pComp->Value(mkNamingCountAdapt(def, "ChildInstance"));

		if(def)
		{
			C4DefGraphics* pGfx = nullptr;
			pComp->Value(mkNamingAdapt(C4DefGraphicsAdapt(pGfx), "ChildMesh"));
			Def = pGfx->pDef;

			if(pGfx->Type != C4DefGraphics::TYPE_Mesh)
				pComp->excCorrupt("ChildMesh points to non-mesh graphics");
			assert(!attach->Child);
			pComp->Value(mkParAdapt(mkNamingContextPtrAdapt(attach->Child, *pGfx->Mesh, "ChildInstance"), C4MeshDenumeratorFactory));
			assert(attach->Child != nullptr);
			attach->OwnChild = true; // Delete the newly allocated child instance when the parent instance is gone

			// TODO: Do we leak pGfx?
		}
		else
		{
			pComp->Value(mkNamingAdapt(Object, "ChildObject"));
			attach->OwnChild = false; // Keep child instance when parent instance is gone since it belongs to a different object
		}
	}
	else
	{
		int32_t def = 0;
		if(Def) ++def;
		pComp->Value(mkNamingCountAdapt(def, "ChildInstance"));

		if(Def)
		{
			assert(attach->OwnChild);
			C4DefGraphics* pGfx = &Def->Graphics;
			assert(pGfx->Type == C4DefGraphics::TYPE_Mesh);
			pComp->Value(mkNamingAdapt(C4DefGraphicsAdapt(pGfx), "ChildMesh"));
			pComp->Value(mkParAdapt(mkNamingContextPtrAdapt(attach->Child, *pGfx->Mesh, "ChildInstance"), C4MeshDenumeratorFactory));
		}
		else
		{
			assert(!attach->OwnChild);
			pComp->Value(mkNamingAdapt(Object, "ChildObject"));
		}
	}
}
Ejemplo n.º 2
0
void C4GraphicsOverlay::CompileFunc(StdCompiler *pComp)
{
	// read ID
	pComp->Value(iID); pComp->Separator();
	// read def-graphics
	pComp->Value(mkDefaultAdapt(C4DefGraphicsAdapt(pSourceGfx), (C4DefGraphics *)NULL));
	pComp->Separator();
	// read mode
	pComp->Value(mkIntAdapt(eMode)); pComp->Separator();
	// read action (identifier)
	pComp->Value(mkStringAdaptMIE(Action)); pComp->Separator();
	// read blit mode
	pComp->Value(dwBlitMode); pComp->Separator();
	// read phase
	pComp->Value(iPhase); pComp->Separator();
	// read transform
	pComp->Separator(StdCompiler::SEP_START);
	pComp->Value(Transform);
	pComp->Separator(StdCompiler::SEP_END);
	// read color-modulation
	if (pComp->Separator())
		pComp->Value(mkIntAdapt(dwClrModulation));
	else
		// default
		if (pComp->isCompiler()) dwClrModulation = 0xffffff;
	// read overlay target object
	if (pComp->Separator())
		pComp->Value(OverlayObj);
	else
		// default
		if (pComp->isCompiler()) OverlayObj = NULL;
	// update used facet according to read data
	if (pComp->isCompiler()) UpdateFacet();
}