#pragma once #include #include #include #include namespace WallpaperEngine::Render::Objects { /** * Clipping masks of a puppet mesh (MDLV 23+), read and turned into draws the way wallpaper64.exe 2.8.42 does: the * loader (sub_140261880) reads the part ranges and the records, the image setup (sub_14020AE00, sub_14020B720) splits * the index buffer into draws and builds the command list the final draw (sub_140208670 / sub_140208C80) walks. */ struct PuppetClipping { enum RecordFlags : uint32_t { /** the targets are drawn additively instead of translucent */ Additive = 0x1, /** the mask is inverted: cleared to white, the shader flips it (g_RenderVar0.x) */ Inverted = 0x2, /** the sources only make the mask, they aren't drawn themselves */ HideSources = 0x4, /** the mask is drawn where its targets are instead of after its last source, not ported */ AtTargets = 0x8, }; struct Part { uint32_t firstIndex = 0; uint32_t indexCount = 0; }; struct Record { /** texture name relative to materials/, sampled through the mesh UVs */ std::string mask; uint32_t flags = 0; /** parts drawn through the mask */ std::vector targets; /** parts that make the mask */ std::vector sources; /** the record whose targets contain every source of this one, its mask is multiplied in */ int parent = -1; }; struct Draw { uint32_t offset = 0; uint32_t count = 0; }; enum Command : int { /** draw the next draw normally */ PlainDraw = 0, /** record: its mask from the next draw, the targets with the one after */ Mask = 1, /** chain length, (record, mask draw) per ancestor, record: like Mask with the ancestors' masks multiplied in */ NestedMask = 2, }; /** * Reads what follows a puppet's index buffer. offset is the end of the index data, nullopt when the file has no * clipping records */ static std::optional read (const std::vector& data, size_t offset, int version, size_t indexCount); /** Splits the mesh's indices into WE's draws and fills commands, false when the records can't be drawn here */ bool build (const std::vector& meshIndices); std::vector parts; std::vector records; std::vector indices; std::vector draws; std::vector commands; }; } // namespace WallpaperEngine::Render::Objects