载入中...
搜索中...
未找到
VoxelWorldTargetModule.cpp
浏览该文件的文档.
2
5
6#include <simplesquirrel/simplesquirrel.hpp>
7
8#include <cstdint>
9#include <functional>
10#include <utility>
11
13
15
16std::unique_ptr<voxel_editing::VoxelWorldTarget> VoxelWorldTargetModule::newTarget(
17 std::string id, voxel::VoxelWorld* world) const {
18 return voxel_editing::createVoxelWorldTarget(std::move(id), world);
19}
20
25
26void VoxelWorldTargetModule::expose(ssq::Table& table) {
27 auto target = table.addClass<voxel_editing::VoxelWorldTarget>(
28 "VoxelWorldTarget",
29 std::function<voxel_editing::VoxelWorldTarget*()>([]() -> voxel_editing::VoxelWorldTarget* {
30 return nullptr;
31 }),
32 true);
33 target.addFunc("getTargetId", [](voxel_editing::VoxelWorldTarget* self) {
34 return self ? self->targetId().value() : std::string{};
35 });
36 target.addFunc("getRevision", [](voxel_editing::VoxelWorldTarget* self) {
37 return self ? static_cast<int64_t>(self->revision()) : int64_t{0};
38 });
40 target.addFunc("writeInt3", [](voxel_editing::VoxelWorldTarget* self, int x, int y, int z, int value) {
41 return self && self->writeInt3(x, y, z, value) == editing::FieldWriteStatus::Applied;
42 });
44 target.addFunc("getDirtyMinX", [](voxel_editing::VoxelWorldTarget* self) {
45 return self ? self->dirtyVolume().minX : 0;
46 });
47 target.addFunc("getDirtyMinY", [](voxel_editing::VoxelWorldTarget* self) {
48 return self ? self->dirtyVolume().minY : 0;
49 });
50 target.addFunc("getDirtyMinZ", [](voxel_editing::VoxelWorldTarget* self) {
51 return self ? self->dirtyVolume().minZ : 0;
52 });
53 target.addFunc("getDirtyMaxX", [](voxel_editing::VoxelWorldTarget* self) {
54 return self ? self->dirtyVolume().maxX : -1;
55 });
56 target.addFunc("getDirtyMaxY", [](voxel_editing::VoxelWorldTarget* self) {
57 return self ? self->dirtyVolume().maxY : -1;
58 });
59 target.addFunc("getDirtyMaxZ", [](voxel_editing::VoxelWorldTarget* self) {
60 return self ? self->dirtyVolume().maxZ : -1;
61 });
62
63 auto module = table.addClass(name, VoxelWorldTargetModule::create, false);
64 expose(module);
65}
66
67void VoxelWorldTargetModule::expose(ssq::Class& cls) {
68 cls.addFunc("create", [](VoxelWorldTargetModule* self, const std::string& id,
69 voxel::VoxelWorld* world) {
70 return self->newTarget(id, world).release();
71 });
72 cls.addFunc("bind", &VoxelWorldTargetModule::bind);
73}
74
75} // namespace eve::voxelworld_target
LogicalId target
double value
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
HSQOBJECT cls
Definition ECS.cpp:21
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
World3D * world
std::function< eve::Result< void >()> release
Definition Procgen.cpp:86
std::string string
std::optional< InteractionSession > session
Definition Tactics.cpp:39
Hosts interchangeable editor tools and routes their lifecycle/input.
Sparse chunk map + visibility selection (frustum + distance + face orientation). Meshing is neighbor-...
Definition VoxelWorld.h:60
Non-owning authoring adapter from a live voxel world to the volume protocol.
int readInt3(int x, int y, int z) const override
Reads int 3.
editing::TargetId targetId() const override
Target id.
void clearDirtyVolume() override
Clears dirty volume.
Script-facing composition module for live voxel-world editing targets.
void bind(editor::EditorSession *session, voxel_editing::VoxelWorldTarget *target) const
Bind borrowed target and session objects without taking ownership. @thread Owner-thread only.
std::unique_ptr< voxel_editing::VoxelWorldTarget > newTarget(std::string id, voxel::VoxelWorld *world) const
Create an independently owned adapter over a borrowed voxel world.
std::unique_ptr< VoxelWorldTarget > createVoxelWorldTarget(std::string id, voxel::VoxelWorld *world)
Create a voxel-world adapter.