8#include <simplesquirrel/simplesquirrel.hpp>
13void ProcgenAnimation::expose(ssq::Table& table) {
14 auto module = table.addClass(name, ProcgenAnimation::create, false);
16 auto plan = table.addClass(
"PcgSkinnedMeshPlan", ssq::Class::Ctor<
PcgSkinnedMeshPlan()>());
22 if (!self || !mesh || !skin || !transform)
23 return eve::script::projectResult(vm, Result<void>::failure(Diagnostic::error(
24 DiagnosticCode::InvalidArgument,
"Pcg skinned plan arguments are required",
25 "procgen.animation.pcgSkinnedMesh")));
26 return eve::script::projectResult(vm, self->appendSource(*mesh, *skin, *transform, material));
29 plan.addFunc(
"getSourceCount", [](
const PcgSkinnedMeshPlan* self) {
30 return self ? self->getSourceCount() : 0;
32 auto result = table.addClass(
"PcgSkinnedMeshResult", ssq::Class::Ctor<PcgSkinnedMeshResult()>());
33 result.addFunc(
"isValid", [](
const PcgSkinnedMeshResult* self) {
return self && self->valid(); });
34 result.addFunc(
"getSkin", [](PcgSkinnedMeshResult* self) {
return self ? self->skin() :
nullptr; });
35 result.addFunc(
"copyMesh", [
vm =
table.getHandle()](
const PcgSkinnedMeshResult* self) -> ssq::Object {
36 const auto*
mesh = self ? self->mesh() :
nullptr;
37 if (!
mesh)
return ssq::Object(
vm);
38 auto object = eve::script::makeOwnedSquirrelInstance<procgen::MeshBuild>(
39 vm, std::make_unique<procgen::MeshBuild>(*
mesh));
41 object.ignore(
"failed to create Pcg combined skinned mesh Squirrel instance");
42 return ssq::Object(
vm);
44 return std::move(
object).takeValue();
48void ProcgenAnimation::expose(ssq::Class&
cls) {
49 cls.addFunc(
"combinePcgSkinnedMeshes", [
vm =
cls.getHandle()](ProcgenAnimation*,
50 PcgSkinnedMeshResult*
output,
51 const PcgSkinnedMeshPlan* plan) {
53 return eve::script::projectResult(vm, Result<void>::failure(Diagnostic::error(
54 DiagnosticCode::InvalidArgument,
"Pcg skinned output and plan are required",
55 "procgen.animation.pcgSkinnedMesh")));
56 return eve::script::projectResult(vm, combinePcgSkinnedMeshesInto(*output, *plan));
#define Module_IMPL(ModuleName, newExpr)
The single Squirrel projection for common Result, Status and Value.
Explicit Value/Owned/Borrowed semantics at the Squirrel boundary.
CPU linear-blend skinning binding for one mesh against an AnimSkeleton.
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
Owned ordered inputs for Pcg's skinned MeshCombiner path.
void clear() noexcept
Remove all sources.
Optional script composition for procedural meshes and skeletal animation.
std::unordered_map< std::string, SkillDefinition > & table()