载入中...
搜索中...
未找到
DestructionDust.cpp
浏览该文件的文档.
2#include <simplesquirrel/simplesquirrel.hpp>
5#include "graphics/Graphics.h"
7#include "graphics/Texture.h"
11namespace eve::physics {
13void DestructionDust::expose(ssq::Table& table) {
14 auto module = table.addClass(name, DestructionDust::create, false);
15 expose(module);
16 auto cls = table.addClass<CollapseDust>("CollapseDust");
17 const auto vm = table.getHandle();
18 cls.addFunc("capture", [vm](CollapseDust* self, fluids::VolumeFluid* source, float time) {
20 : Result<void>::failure(Diagnostic::error(
21 DiagnosticCode::InvalidArgument, "source required", "source")));
22 });
23 cls.addFunc("present", [vm](CollapseDust* self, fluids::VolumeFluid* target, float time) {
24 return script::projectResult(vm, target ? self->present(*target, time)
25 : Result<void>::failure(Diagnostic::error(
26 DiagnosticCode::InvalidArgument, "target required", "target")));
27 });
28 cls.addFunc("save", [vm](CollapseDust* self, const std::string& path) {
29 return script::projectResult(vm, self->save(path));
30 });
31 cls.addFunc("load", [vm](CollapseDust* self, const std::string& path) {
32 return script::projectResult(vm, self->load(path));
33 });
34 cls.addFunc(
35 "injectFog", [vm](CollapseDust* self, graphics::Volumetric* fog, float time, float density, float radius) {
37 vm, fog && fog->getAtmosphereVolume()
38 ? self->injectFog(*fog->getAtmosphereVolume(), fog->getInvViewProj(), time, density, radius)
39 : Result<void>::failure(
40 Diagnostic::error(DiagnosticCode::InvalidArgument, "prepared fog required", "fog")));
41 });
42 cls.addFunc("updateDepthTexture", [vm](CollapseDust* self, graphics::Graphics* graphics, graphics::Texture* texture,
43 CollapseAnimation* clip, float time, graphics::Camera3D* camera) {
45 vm, graphics && texture && clip && camera
46 ? self->updateDepthTexture(*graphics, *texture, *clip, time, *camera)
47 : Result<void>::failure(
48 Diagnostic::error(DiagnosticCode::InvalidArgument, "depth arguments required", "depth")));
49 });
50 cls.addFunc(
51 "prepareFog", [vm](CollapseDust* self, CollapseAnimation* clip, int dw, int dh, int gw, int gh, int gd) {
52 return script::projectResult(vm, clip ? self->prepareFog(*clip, dw, dh, gw, gh, gd)
53 : Result<void>::failure(Diagnostic::error(
54 DiagnosticCode::InvalidArgument, "clip required", "clip")));
55 });
56 cls.addFunc("updateFog", [vm](CollapseDust* self, graphics::Volumetric* fog, graphics::Graphics* graphics,
57 float time, graphics::Camera3D* camera, float density, float radius) {
58 if (!fog || !graphics || !camera)
61 Diagnostic::error(DiagnosticCode::InvalidArgument, "fog update arguments required", "fog")));
62 auto result = self->updateFog(*fog, *graphics, time, *camera, density, radius);
63 if (!result) return script::projectStatusResult(vm, result.status());
64 return script::projectResult(vm, Result<int>::success(static_cast<int>(result.value())),
65 [](int value) { return Value(value); });
66 });
67 cls.addFunc("frameCount", &CollapseDust::frameCount);
68 cls.addFunc("prepareDepth", [vm](CollapseDust* self, int width, int height) {
69 return script::projectResult(vm, self->prepareDepth(width, height));
70 });
71}
72void DestructionDust::expose(ssq::Class&) {}
73} // namespace eve::physics
LogicalId target
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
float density
glm::vec4 clip
std::uint32_t height
std::uint32_t width
Poco::JSON::Object::Ptr result
double radius
Definition MeleeHit.cpp:42
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:27
std::string error
Definition Package.cpp:174
Texture * texture
std::string path
Definition PlayHost.cpp:111
Object::Ptr value
std::string_view source
The single Squirrel projection for common Result, Status and Value.
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
CPU position-based free-volume fluid with a bounded spatial grid. @ownership Owns all particle state;...
Owning gas presentation cache, independent of the source solver. @ownership Owns frames and depth scr...
Result< void > capture(const fluids::VolumeFluid &source, float seconds)
Capture gas particles, fading their final two seconds. @cost Linear in live particles,...
int frameCount() const
Recorded frame count.
Optional fluid-backed destruction presentation module; no ECS systems or retained service links.
eve::Diagnostic Diagnostic
eve::Result< T > Result
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47