载入中...
搜索中...
未找到
PointSet.cpp
浏览该文件的文档.
26float pointSegmentDistanceSquared(float px, float pz, const ProcgenPoint& a, const ProcgenPoint& b) {
30 const float t = length2 > 0.f ? std::clamp(((px - a.x) * vx + (pz - a.z) * vz) / length2, 0.f, 1.f) : 0.f;
41 const bool crosses = ((a.z > z) != (b.z > z)) && (x < (b.x - a.x) * (z - a.z) / (b.z - a.z) + a.x);
73 Diagnostic::error(DiagnosticCode::InvalidArgument, "source point index is out of range", "sourceIndex"));
82 EV_ASSERT(attributeRow.value() + 1 == points_.size(), "PointSet point and attribute rows must remain aligned");
203void PointSet::setBounds(int index, float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
340 trySetFloatAttribute(index, name, value).ignore("compatibility PointSet float attribute setter");
352Result<void> PointSet::trySetIntAttribute(int index, const std::string& name, std::int64_t value) {
360 trySetIntAttribute(index, name, value).ignore("compatibility PointSet integer attribute setter");
363std::int64_t PointSet::getIntAttribute(int index, const std::string& name, std::int64_t fallback) const {
380 trySetBoolAttribute(index, name, value).ignore("compatibility PointSet Boolean attribute setter");
392Result<void> PointSet::trySetVectorAttribute(int index, const std::string& name, float x, float y, float z) {
399void PointSet::setVectorAttribute(int index, const std::string& name, float x, float y, float z) {
422Result<void> PointSet::trySetStringAttribute(int index, const std::string& name, const std::string& value) {
429void PointSet::setStringAttribute(int index, const std::string& name, const std::string& value) {
430 trySetStringAttribute(index, name, value).ignore("compatibility PointSet string attribute setter");
433std::string PointSet::getStringAttribute(int index, const std::string& name, const std::string& fallback) const {
610PointSet filterPointBox(const PointSet& input, float minX, float minY, float minZ, float maxX, float maxY, float maxZ,
653PointSet filterPointsBySplineDistance(const PointSet& input, const PointSet& controlPoints, float minDistance,
686Result<PointSet> excludePointsByGridMask(const PointSet& input, const Grid2D& mask, float originX, float originZ,
688 if (mask.getWidth() <= 0 || mask.getHeight() <= 0 || !std::isfinite(originX) || !std::isfinite(originZ) ||
689 !std::isfinite(cellSize) || cellSize <= 0.f || semantic < 0 || !std::isfinite(clearance) || clearance < 0.f ||
802 for (size_t index = 0; index < first.points().size(); ++index) appendPointRow(output, first, index);
837void rotateEuler(float& x, float& y, float& z, float pitchDegrees, float yawDegrees, float rollDegrees) {
862 if (identities.insert(identityOf(first.points()[index])).second) appendPointRow(result, first, index);
864 if (identities.insert(identityOf(second.points()[index])).second) appendPointRow(result, second, index);
875 if (identities.contains(identityOf(first.points()[index]))) appendPointRow(result, first, index);
886 if (!identities.contains(identityOf(first.points()[index]))) appendPointRow(result, first, index);
890PointSet transformPointSet(const PointSet& input, float translateX, float translateY, float translateZ,
892 return transformPointSet3D(input, translateX, translateY, translateZ, 0.f, yawDegrees, 0.f, scaleX, scaleY, scaleZ);
895PointSet transformPointSet3D(const PointSet& input, float translateX, float translateY, float translateZ,
918 rotateEuler(point.normalX, point.normalY, point.normalZ, pitchDegrees, yawDegrees, rollDegrees);
930PointSet copyPointsToTargets(const PointSet& source, const PointSet& targets, bool inheritTargetAttributes) {
962 const std::uint64_t sourceIdentity = sourcePoint.id != 0 ? sourcePoint.id : std::uint64_t(sourcePoint.seed);
1037PointSet remapPointDensity(const PointSet& input, float inputMin, float inputMax, float outputMin, float outputMax,
1074PointSet densityFromNormal(const PointSet& input, float minDegrees, float maxDegrees, float outputMin, float outputMax,
1093PointSet modifyPointBounds(const PointSet& input, float scaleX, float scaleY, float scaleZ, float padX, float padY,
EVEngine assertion entry point, backed by zeroerr.
#define EV_ASSERT(cond,...)
Assert an internal engine invariant (state that must always hold).
Definition Assert.h:37
#define EV_PARAM_CHECK(cond,...)
Validate a function parameter / public API precondition.
Definition Assert.h:30
Stable, structured diagnostics shared by engine modules.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:571
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
std::optional< std::string_view > getString(std::size_t row, std::string_view name) const
Borrow a string value until the next table mutation, or return no value.
Definition AttributeTable.cpp:238
Result< void > copyColumn(std::string_view from, std::string_view to)
Copy one typed column onto another name, creating or overwriting a compatible target.
Definition AttributeTable.cpp:128
std::optional< std::int64_t > getInt(std::size_t row, std::string_view name) const
Read an integer value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:229
bool has(std::size_t row, std::string_view name) const
Return whether a row contains a value in the named column.
Definition AttributeTable.cpp:72
std::optional< ProcgenAttributeVector > getVector(std::size_t row, std::string_view name) const
Read a vector value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:235
std::size_t appendRow()
Append one empty row and return its stable row index.
Definition AttributeTable.cpp:16
std::optional< bool > getBool(std::size_t row, std::string_view name) const
Read a Boolean value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:232
Result< void > removeColumn(std::string_view name)
Remove one metadata column and its values from every row.
Definition AttributeTable.cpp:111
Result< void > setBool(std::size_t row, std::string_view name, bool value)
Set a Boolean value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:217
Result< void > setInt(std::size_t row, std::string_view name, std::int64_t value)
Set an integer value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:214
Result< void > setFloat(std::size_t row, std::string_view name, float value)
Set a float value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:211
Result< std::size_t > appendRowFrom(const AttributeTable &source, std::size_t sourceRow)
Append one row copied from another table, merging compatible schema columns.
Definition AttributeTable.cpp:21
Result< void > setVector(std::size_t row, std::string_view name, ProcgenAttributeVector value)
Set a vector value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:220
Result< void > renameColumn(std::string_view from, std::string_view to)
Rename one metadata column without changing values or type.
Definition AttributeTable.cpp:78
Result< void > setString(std::size_t row, std::string_view name, std::string value)
Set a string value, rejecting an incompatible existing schema.
Definition AttributeTable.cpp:223
void resize(std::size_t rows)
Resize every column to the same row count.
Definition AttributeTable.cpp:12
Result< void > clearRow(std::size_t row)
Clear every value in one row while preserving the table schema.
Definition AttributeTable.cpp:53
std::optional< float > getFloat(std::size_t row, std::string_view name) const
Read a float value, or no value for an absent row, name, or type.
Definition AttributeTable.cpp:226
std::optional< ProcgenAttributeType > typeOf(std::string_view name) const
Return the declared type for a name, or no value when absent.
Definition AttributeTable.cpp:68
Intermediate 2D generation result. cells store semantic ids (see Semantic.h), not tile GIDs — convert...
Definition Grid2D.h:37
std::string getAttributeType(int index, const std::string &name) const
Return float, int, bool, vector, string, or empty when the attribute is absent.
Definition PointSet.cpp:454
Result< void > trySetPointId(int index, std::uint64_t id)
Assign a unique non-zero point identity without mutating on failure.
Definition PointSet.cpp:295
void setFloatAttribute(int index, const std::string &name, float value)
Compatibility-only unchecked script setter; canonical code uses trySetFloatAttribute.
Definition PointSet.cpp:339
float getBoundsMinX(int index) const
Return the local-space minimum X bound.
Definition PointSet.cpp:214
bool hasVectorAttribute(int index, const std::string &name) const
Test whether vector metadata exists.
Definition PointSet.cpp:418
bool hasStringAttribute(int index, const std::string &name) const
True when string attribute.
Definition PointSet.cpp:438
bool hasIntAttribute(int index, const std::string &name) const
Test whether signed integer metadata exists.
Definition PointSet.cpp:368
bool hasBoolAttribute(int index, const std::string &name) const
Test whether boolean metadata exists.
Definition PointSet.cpp:388
float getFloatAttribute(int index, const std::string &name, float fallback) const
Returns the float attribute.
Definition PointSet.cpp:343
float getBoundsMaxZ(int index) const
Return the local-space maximum Z bound.
Definition PointSet.cpp:234
Result< void > tryCopyAttribute(const std::string &from, const std::string &to)
Copy one metadata column onto another name on this set.
Definition PointSet.cpp:450
float getBoundsMaxY(int index) const
Return the local-space maximum Y bound.
Definition PointSet.cpp:230
Result< void > clearPointAttributes(std::size_t index)
Clear all metadata values on an existing point while retaining the set schema.
Definition PointSet.cpp:86
float getBoundsMaxX(int index) const
Return the local-space maximum X bound.
Definition PointSet.cpp:226
Result< void > trySetStringAttribute(int index, const std::string &name, const std::string &value)
Canonical checked string metadata write.
Definition PointSet.cpp:422
Result< void > tryRenameAttribute(const std::string &from, const std::string &to)
Rename one metadata column on this set.
Definition PointSet.cpp:442
std::string getStringAttribute(int index, const std::string &name, const std::string &fallback) const
Returns the string attribute.
Definition PointSet.cpp:433
void setColor(int index, float red, float green, float blue, float alpha)
Set the normalized linear RGBA point color.
Definition PointSet.cpp:239
float getVectorAttributeY(int index, const std::string &name, float fallback) const
Read the Y component of vector metadata or the caller-provided default.
Definition PointSet.cpp:408
Result< void > trySetBoolAttribute(int index, const std::string &name, bool value)
Canonical checked Boolean metadata write.
Definition PointSet.cpp:372
void setIntAttribute(int index, const std::string &name, std::int64_t value)
Compatibility-only unchecked script setter; canonical code uses trySetIntAttribute.
Definition PointSet.cpp:359
float getBoundsMinY(int index) const
Return the local-space minimum Y bound.
Definition PointSet.cpp:218
ProcgenPoint & mutablePoint(std::size_t index)
Mutably access one existing point without changing row structure.
Definition PointSet.cpp:93
Result< void > trySetVectorAttribute(int index, const std::string &name, float x, float y, float z)
Canonical checked vector metadata write.
Definition PointSet.cpp:392
void setBounds(int index, float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
Set local-space point bounds before scale and rotation are applied.
Definition PointSet.cpp:203
Result< void > assignPointIds(std::uint64_t namespaceId)
Fill zero identities deterministically and reject pre-existing duplicates.
Definition PointSet.cpp:311
bool hasFloatAttribute(int index, const std::string &name) const
True when float attribute.
Definition PointSet.cpp:348
float getPitch(int index) const
Return the point's local pitch in degrees.
Definition PointSet.cpp:172
void setBoolAttribute(int index, const std::string &name, bool value)
Compatibility-only unchecked script setter; canonical code uses trySetBoolAttribute.
Definition PointSet.cpp:379
std::uint64_t getPointId(int index) const
Return the stable point identity, or zero when it has not been assigned.
Definition PointSet.cpp:290
float getVectorAttributeZ(int index, const std::string &name, float fallback) const
Read the Z component of vector metadata or the caller-provided default.
Definition PointSet.cpp:413
void setVectorAttribute(int index, const std::string &name, float x, float y, float z)
Compatibility-only unchecked script setter; canonical code uses trySetVectorAttribute.
Definition PointSet.cpp:399
void setSteepness(int index, float steepness)
Set normalized surface steepness metadata in the inclusive range [0, 1].
Definition PointSet.cpp:265
bool getBoolAttribute(int index, const std::string &name, bool fallback) const
Read boolean metadata or return the caller-provided default when absent.
Definition PointSet.cpp:383
int appendPoint(ProcgenPoint point)
Append a point with an empty attribute row and return its row index.
Definition PointSet.cpp:63
void setStringAttribute(int index, const std::string &name, const std::string &value)
Compatibility-only unchecked script setter; canonical code uses trySetStringAttribute.
Definition PointSet.cpp:429
const std::vector< ProcgenPoint > & points() const
Borrow immutable point rows; structural ownership remains with this set.
Definition PointSet.h:212
float getVectorAttributeX(int index, const std::string &name, float fallback) const
Read the X component of vector metadata or the caller-provided default.
Definition PointSet.cpp:403
Result< void > trySetIntAttribute(int index, const std::string &name, std::int64_t value)
Canonical checked signed integer metadata write.
Definition PointSet.cpp:352
std::int64_t getIntAttribute(int index, const std::string &name, std::int64_t fallback) const
Read signed integer metadata or return the caller-provided default when absent.
Definition PointSet.cpp:363
float getSteepness(int index) const
Return normalized point steepness metadata.
Definition PointSet.cpp:269
Result< int > appendPointFrom(const PointSet &source, std::size_t sourceIndex)
Append a point and its attributes from another set.
Definition PointSet.cpp:70
void setRotation(int index, float pitch, float yaw, float roll)
Set the point's local Euler rotation in degrees.
Definition PointSet.cpp:164
const AttributeTable & attributes() const noexcept
Borrow the authoritative schema-bearing attribute table.
Definition PointSet.h:216
float getBoundsMinZ(int index) const
Return the local-space minimum Z bound.
Definition PointSet.cpp:222
Result< void > trySetFloatAttribute(int index, const std::string &name, float value)
Canonical checked float metadata write.
Definition PointSet.cpp:332
Result< void > tryDeleteAttribute(const std::string &name)
Delete one metadata column on this set.
Definition PointSet.cpp:446
void reserve(std::size_t count)
Reserve point storage without changing point or attribute row counts.
Definition PointSet.cpp:61
bool pointInPolygon(float px, float py, const std::vector< HousePolygonPoint > &poly)
Ray-casting point-in-polygon test in corner coordinates.
Definition HouseGenerationAlgorithms.cpp:100
Definition EvpackPointGraphLoader.h:12
PointSet samplePolylinePoints(const PointSet &controlPoints, float spacing, uint32_t seed, float lateralJitter)
Sample polyline points.
Definition PointSet.cpp:761
PointSet transformPointSet3D(const PointSet &input, float translateX, float translateY, float translateZ, float pitchDegrees, float yawDegrees, float rollDegrees, float scaleX, float scaleY, float scaleZ)
Apply translation, pitch/yaw/roll rotation and non-uniform scale.
Definition PointSet.cpp:895
PointSet densityFromNormal(const PointSet &input, float minDegrees, float maxDegrees, float outputMin, float outputMax, bool invert)
Remap surface slope (from normals) into density.
Definition PointSet.cpp:1074
PointSet filterPointStringAttribute(const PointSet &input, const std::string &name, const std::string &value, bool invert)
Select points whose named string attribute equals a value.
Definition PointSet.cpp:1051
PointSet unionPointSets(const PointSet &first, const PointSet &second)
Stable union by non-zero point id, with legacy position-and-seed fallback.
Definition PointSet.cpp:856
PointSet transformPointSet(const PointSet &input, float translateX, float translateY, float translateZ, float yawDegrees, float scaleX, float scaleY, float scaleZ)
Apply translation, yaw rotation and non-uniform scale to points and their transforms.
Definition PointSet.cpp:890
PointSet filterPointsByPolygon(const PointSet &input, const PointSet &polygon, bool invert)
Filter points by polygon.
Definition PointSet.cpp:642
PointSet filterPointBox(const PointSet &input, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, bool invert)
Filter point box.
Definition PointSet.cpp:610
PointSet filterPointSlope(const PointSet &input, float minDegrees, float maxDegrees)
Filter point slope.
Definition PointSet.cpp:625
PointSet assignWeightedMeshAttribute(const PointSet &input, uint32_t seed, const std::string &attribute, const std::string *meshes, const float *weights, int entryCount)
Deterministically assign a weighted mesh path string attribute.
Definition PointSet.cpp:1126
PointSet poissonDiskPoints(int width, int depth, float radius, uint32_t seed, int maxPoints)
Bridson blue-noise (Poisson disk) samples in a width x depth area (XZ, y=0).
Definition PointSet.cpp:506
PointSet filterPointsBySplineDistance(const PointSet &input, const PointSet &controlPoints, float minDistance, float maxDistance)
Filter points by spline distance.
Definition PointSet.cpp:653
PointSet excludePointRadius(const PointSet &input, float x, float z, float radius)
Exclude point radius.
Definition PointSet.cpp:674
PointSet intersectPointSets(const PointSet &first, const PointSet &second)
Keep first-set points whose stable or legacy identity occurs in the second set.
Definition PointSet.cpp:868
void appendPointRow(PointSet &output, const PointSet &input, std::size_t index)
Definition PointSet.cpp:57
PointSet mergePointSets(const PointSet &first, const PointSet &second)
Concatenate two attributed point collections while preserving order.
Definition PointSet.cpp:799
PointSet copyPointsToTargets(const PointSet &source, const PointSet &targets, bool inheritTargetAttributes)
Instantiate source points relative to targets in stable target-major order.
Definition PointSet.cpp:930
PointSet filterPointDensity(const PointSet &input, float minDensity, float maxDensity)
Filter point density.
Definition PointSet.cpp:601
std::uint64_t derivePointId(std::uint64_t namespaceId, std::uint64_t ordinal)
Deterministically derive a non-zero stable point identity.
Definition PointSet.cpp:470
PointSet selfPrunePoints(const PointSet &input, float radius)
Self prune points.
Definition PointSet.cpp:741
std::string_view procgenAttributeTypeName(ProcgenAttributeType type) noexcept
Return the stable script/persistence name for an attribute type.
Definition AttributeTable.cpp:246
PointSet filterPointHeight(const PointSet &input, float minHeight, float maxHeight)
Filter point height.
Definition PointSet.cpp:592
PointSet modifyPointBounds(const PointSet &input, float scaleX, float scaleY, float scaleZ, float padX, float padY, float padZ)
Scale and pad each point's local bounds about its center.
Definition PointSet.cpp:1093
PointSet densityCullPoints(const PointSet &input, uint32_t seed, float multiplier)
Deterministically keep points according to density and a root seed.
Definition PointSet.cpp:1062
PointSet differencePointSets(const PointSet &first, const PointSet &second)
Remove first-set points whose stable or legacy identity occurs in the second set.
Definition PointSet.cpp:879
uint32_t deriveSeed(uint32_t parent, const std::string &scope)
Stable label-based seed derivation; independent pipeline branches do not perturb each other.
Definition PointSet.cpp:460
PointSet jitterPointPositions(const PointSet &input, uint32_t seed, float amountX, float amountZ)
Jitter point positions.
Definition PointSet.cpp:728
PointSet remapPointDensity(const PointSet &input, float inputMin, float inputMax, float outputMin, float outputMax, bool clampOutput)
Linearly remap point density between ranges with optional output clamping.
Definition PointSet.cpp:1037
PointSet sampleGridPoints(int width, int depth, float spacing, uint32_t seed, float jitter)
Sample grid points.
Definition PointSet.cpp:484
Result< PointSet > excludePointsByGridMask(const PointSet &input, const Grid2D &mask, float originX, float originZ, float cellSize, int semantic, float clearance, std::size_t maximumChecks)
Remove points covered by a semantic grid mask plus optional world-space clearance.
Definition PointSet.cpp:686
@ InvalidArgument
@ PreconditionViolation
@ Conflict
Definition Container.h:602
One deterministic sample used by script-first procedural pipelines.
Definition PointSet.h:17
std::uint64_t id
Stable non-zero identity; zero marks legacy or not-yet-assigned data.
Definition PointSet.h:19