Polyphase Game Engine
Loading...
Searching...
No Matches
VoxelSculptManager.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include "Maths.h"
6#include <vector>
7#include <set>
8#include <cstdint>
9
10class Voxel3D;
11class Node;
12
13enum class VoxelSculptMode : uint8_t
14{
15 Add = 0,
16 Remove,
17 Paint,
18 Count
19};
20
21struct VoxelChange
22{
23 int32_t x, y, z;
24 uint8_t oldValue;
25 uint8_t newValue;
26};
27
28struct VoxelSculptOptions
29{
30 VoxelSculptMode mMode = VoxelSculptMode::Add;
31 int32_t mBrushRadius = 1;
32 uint8_t mMaterialId = 1;
33};
34
35class VoxelSculptManager
36{
37public:
38 VoxelSculptManager();
39 ~VoxelSculptManager();
40
41 void Update();
42 void HandleNodeDestroy(Node* node);
43
44 VoxelSculptOptions mOptions;
45
46 // Hover state (read by UI panel)
47 bool mHoverValid = false;
48 glm::ivec3 mHoverVoxel = {};
49 glm::ivec3 mHoverPlaceVoxel = {};
50
51private:
52 void UpdateHover();
53 void UpdateStroke();
54 void CommitStroke();
55 void DrawCursor();
56 void ApplyBrush(Voxel3D* voxel, glm::ivec3 center);
57
58 // Key helper to avoid duplicate changes in one stroke
59 static uint64_t VoxelKey(int32_t x, int32_t y, int32_t z);
60
61 // Stroke state
62 bool mStrokeActive = false;
63 Voxel3D* mPendingTarget = nullptr;
64 std::vector<VoxelChange> mPendingChanges;
65 std::set<uint64_t> mModifiedSet;
66};
67
68#endif
bool Update()
Definition Engine.cpp:710
Definition Node.h:67
Definition Voxel3d.h:61