载入中...
搜索中...
未找到
TerrainObjectPlacement.h
浏览该文件的文档.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <string>
6#include <vector>
7
8#include "common/Result.h"
9
10namespace eve::procgen {
11class Heightmap;
12class PointSet;
13struct TerrainStampSettings;
14struct TerrainMultiTileReport;
15
19enum class TerrainObjectYOffsetMode : std::uint8_t { TerrainHeight, SeaLevel, Custom };
21enum class TerrainObjectOperationMode : std::uint8_t { Add, Replace, Remove };
22
48
51 float originX = 0, originZ = 0, width = 1, depth = 1, heightScale = 1;
52 float spacing = 10, spawnDensity = 1, jitterPercent = 0.5F;
53 float startOffsetX = 0, startOffsetZ = 0;
54 float failureRate = 0, minimumFitness = 0.5F, minimumInstanceFitness = 0.5F;
55 float minimumDirection = 0, maximumDirection = 360;
56 float boundsRadius = 1, boundsCheckQuality = 100, prototypeScale = 1;
57 bool boundsCollisionCheck = false;
58 float seaLevel = 0;
59 std::int32_t seed = 1;
60 std::uint64_t namespaceId = 1;
61 int maxPoints = 1000000;
62 std::string prototype;
63 std::vector<TerrainObjectInstanceSettings> instances;
65 [[nodiscard]] Result<int> addInstance(const TerrainObjectInstanceSettings& instance);
66};
67
80 PointSet& output, const Heightmap& fitness, const Heightmap& heights,
82
88 const Heightmap& fitness,
90 float removalStrength);
91
94 std::string name;
95 PointSet* objects = nullptr;
96 const Heightmap* heights = nullptr;
97 double originX = 0, originZ = 0, width = 1, depth = 1;
99 bool worldMap = false;
100};
101
109 const std::vector<TerrainObjectTile>& tiles, const Heightmap& operationFitness,
110 const TerrainObjectPlacementSettings& settings, const TerrainStampSettings& operationSettings,
111 TerrainObjectOperationMode mode, bool worldMapOperation,
112 const std::vector<std::string>& validTerrainNames = {});
113
116public:
128 [[nodiscard]] Result<int> addTile(const std::string& name, const PointSet& objects, const Heightmap& heights,
129 double originX, double originZ, double width, double depth,
130 int resolutionX, int resolutionY, bool worldMap = false);
132 [[nodiscard]] Result<int> apply(const Heightmap& fitness, const TerrainObjectPlacementSettings& settings,
133 const TerrainStampSettings& operationSettings, TerrainObjectOperationMode mode,
134 bool worldMapOperation = false);
136 [[nodiscard]] Result<int> copyTile(const std::string& name, PointSet& output) const;
138 [[nodiscard]] Result<int> undo();
140 [[nodiscard]] Result<int> redo();
142 [[nodiscard]] int getTileCount() const noexcept;
144 [[nodiscard]] int getLastChangedSamples() const noexcept;
146 [[nodiscard]] int getLastAffectedTiles() const noexcept;
148 [[nodiscard]] int getOperationCount() const noexcept;
150 [[nodiscard]] int getAppliedCount() const noexcept;
151private:
152 struct Impl;
153 std::unique_ptr<Impl> impl_;
154};
155} // namespace eve::procgen
std::string output
EvpackChunkInput input
Definition Evpack.cpp:170
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::uint32_t width
std::string name
std::uint32_t seed
Definition PointSet.cpp:807
Move-only, checked operation results for the common layer.
TerrainThermalSettings settings
int spacing
std::uint32_t depth
std::vector< WfcTile > tiles
Definition WfcSimple.cpp:22
Move-only operation result carrying either a value or Status.
Definition Result.h:155
In-memory terrain heightmap: a dense float grid (row-major, index = y * width + x) materialized from ...
Definition Heightmap.h:21
Script-friendly collection of attributed 3D samples.
Definition PointSet.h:59
Owning transactional multi-terrain object workspace with undo and redo snapshots.
~TerrainMultiObjectWorkspace()
Terrain multi object workspace.
TerrainMultiObjectWorkspace(TerrainMultiObjectWorkspace &&) noexcept
Terrain multi object workspace.
Result< int > removeTerrainObjectPoints(PointSet &output, const PointSet &input, const Heightmap &fitness, const TerrainObjectPlacementSettings &s, float removalStrength)
Remove matching prototype points wherever fitness is strictly above removalStrength.
Result< TerrainMultiTileReport > applyTerrainObjectsMultiTile(const std::vector< TerrainObjectTile > &tiles, const Heightmap &fitness, const TerrainObjectPlacementSettings &s, const TerrainStampSettings &operationSettings, TerrainObjectOperationMode mode, bool worldMapOperation, const std::vector< std::string > &validTerrainNames)
Apply one Pcg-style game-object rule over mapped terrain tiles atomically.
TerrainObjectScaleMode
Pcg-compatible scale policy for one terrain object instance resource.
Result< int > exportTerrainObjectPoints(PointSet &output, const Heightmap &fitness, const Heightmap &heights, const TerrainObjectPlacementSettings &s)
Export Pcg-style terrain game-object resources into an attributed PointSet atomically.
TerrainObjectYOffsetMode
Height reference used by one terrain object instance resource.
TerrainObjectOperationMode
Mutation performed by a multi-terrain game-object operation.
One resource entry emitted around each accepted Pcg game-object prototype location.
Deterministic Pcg SetTerrainGameObjects scan, collision and resource configuration.
std::vector< TerrainObjectInstanceSettings > instances
One exclusively borrowed terrain object owner and its immutable height source.
Value configuration for a rectangular stamp in world X/Z coordinates.