载入中...
搜索中...
未找到
PointSet.cpp
浏览该文件的文档.
25float pointSegmentDistanceSquared(float px, float pz, const ProcgenPoint& a, const ProcgenPoint& b) {
29 const float t = length2 > 0.f ? std::clamp(((px - a.x) * vx + (pz - a.z) * vz) / length2, 0.f, 1.f) : 0.f;
40 const bool crosses = ((a.z > z) != (b.z > z)) && (x < (b.x - a.x) * (z - a.z) / (b.z - a.z) + a.x);
72 Diagnostic::error(DiagnosticCode::InvalidArgument, "source point index is out of range", "sourceIndex"));
81 EV_ASSERT(attributeRow.value() + 1 == points_.size(), "PointSet point and attribute rows must remain aligned");
202void PointSet::setBounds(int index, float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
339 trySetFloatAttribute(index, name, value).ignore("compatibility PointSet float attribute setter");
351Result<void> PointSet::trySetIntAttribute(int index, const std::string& name, std::int64_t value) {
359 trySetIntAttribute(index, name, value).ignore("compatibility PointSet integer attribute setter");
362std::int64_t PointSet::getIntAttribute(int index, const std::string& name, std::int64_t fallback) const {
379 trySetBoolAttribute(index, name, value).ignore("compatibility PointSet Boolean attribute setter");
391Result<void> PointSet::trySetVectorAttribute(int index, const std::string& name, float x, float y, float z) {
398void PointSet::setVectorAttribute(int index, const std::string& name, float x, float y, float z) {
421Result<void> PointSet::trySetStringAttribute(int index, const std::string& name, const std::string& value) {
428void PointSet::setStringAttribute(int index, const std::string& name, const std::string& value) {
429 trySetStringAttribute(index, name, value).ignore("compatibility PointSet string attribute setter");
432std::string PointSet::getStringAttribute(int index, const std::string& name, const std::string& fallback) const {
606PointSet filterPointBox(const PointSet& input, float minX, float minY, float minZ, float maxX, float maxY, float maxZ,
649PointSet filterPointsBySplineDistance(const PointSet& input, const PointSet& controlPoints, float minDistance,
682Result<PointSet> excludePointsByGridMask(const PointSet& input, const Grid2D& mask, float originX, float originZ,
684 if (mask.getWidth() <= 0 || mask.getHeight() <= 0 || !std::isfinite(originX) || !std::isfinite(originZ) ||
685 !std::isfinite(cellSize) || cellSize <= 0.f || semantic < 0 || !std::isfinite(clearance) || clearance < 0.f ||
798 for (size_t index = 0; index < first.points().size(); ++index) appendPointRow(output, first, index);
833void rotateEuler(float& x, float& y, float& z, float pitchDegrees, float yawDegrees, float rollDegrees) {
858 if (identities.insert(identityOf(first.points()[index])).second) appendPointRow(result, first, index);
860 if (identities.insert(identityOf(second.points()[index])).second) appendPointRow(result, second, index);
871 if (identities.contains(identityOf(first.points()[index]))) appendPointRow(result, first, index);
882 if (!identities.contains(identityOf(first.points()[index]))) appendPointRow(result, first, index);
886PointSet transformPointSet(const PointSet& input, float translateX, float translateY, float translateZ,
888 return transformPointSet3D(input, translateX, translateY, translateZ, 0.f, yawDegrees, 0.f, scaleX, scaleY, scaleZ);
891PointSet transformPointSet3D(const PointSet& input, float translateX, float translateY, float translateZ,
914 rotateEuler(point.normalX, point.normalY, point.normalZ, pitchDegrees, yawDegrees, rollDegrees);
926PointSet copyPointsToTargets(const PointSet& source, const PointSet& targets, bool inheritTargetAttributes) {
958 const std::uint64_t sourceIdentity = sourcePoint.id != 0 ? sourcePoint.id : std::uint64_t(sourcePoint.seed);
1003 result.trySetFloatAttribute(resultIndex, name, *source.attributes().getFloat(sourceIndex, name))
1033PointSet remapPointDensity(const PointSet& input, float inputMin, float inputMax, float outputMin, float outputMax,
1070PointSet densityFromNormal(const PointSet& input, float minDegrees, float maxDegrees, float outputMin, float outputMax,
1089PointSet modifyPointBounds(const PointSet& input, float scaleX, float scaleY, float scaleZ, float padX, float padY,
#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={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
void expect(std::string_view message) const
Require success for a void operation.
Definition Result.h:548
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:537
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
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
std::string_view columnName(std::size_t index) const noexcept
Return a stable insertion-ordered column name or an empty string.
Definition AttributeTable.cpp:65
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:36
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:453
Result< void > trySetPointId(int index, std::uint64_t id)
Assign a unique non-zero point identity without mutating on failure.
Definition PointSet.cpp:294
void setFloatAttribute(int index, const std::string &name, float value)
Compatibility-only unchecked script setter; canonical code uses trySetFloatAttribute.
Definition PointSet.cpp:338
float getBoundsMinX(int index) const
Return the local-space minimum X bound.
Definition PointSet.cpp:213
bool hasVectorAttribute(int index, const std::string &name) const
Test whether vector metadata exists.
Definition PointSet.cpp:417
bool hasStringAttribute(int index, const std::string &name) const
True when string attribute.
Definition PointSet.cpp:437
bool hasIntAttribute(int index, const std::string &name) const
Test whether signed integer metadata exists.
Definition PointSet.cpp:367
bool hasBoolAttribute(int index, const std::string &name) const
Test whether boolean metadata exists.
Definition PointSet.cpp:387
float getFloatAttribute(int index, const std::string &name, float fallback) const
Returns the float attribute.
Definition PointSet.cpp:342
float getBoundsMaxZ(int index) const
Return the local-space maximum Z bound.
Definition PointSet.cpp:233
Result< void > tryCopyAttribute(const std::string &from, const std::string &to)
Copy one metadata column onto another name on this set.
Definition PointSet.cpp:449
float getBoundsMaxY(int index) const
Return the local-space maximum Y bound.
Definition PointSet.cpp:229
Result< void > clearPointAttributes(std::size_t index)
Clear all metadata values on an existing point while retaining the set schema.
Definition PointSet.cpp:85
float getBoundsMaxX(int index) const
Return the local-space maximum X bound.
Definition PointSet.cpp:225
Result< void > trySetStringAttribute(int index, const std::string &name, const std::string &value)
Canonical checked string metadata write.
Definition PointSet.cpp:421
Result< void > tryRenameAttribute(const std::string &from, const std::string &to)
Rename one metadata column on this set.
Definition PointSet.cpp:441
std::string getStringAttribute(int index, const std::string &name, const std::string &fallback) const
Returns the string attribute.
Definition PointSet.cpp:432
void setColor(int index, float red, float green, float blue, float alpha)
Set the normalized linear RGBA point color.
Definition PointSet.cpp:238
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:407
Result< void > trySetBoolAttribute(int index, const std::string &name, bool value)
Canonical checked Boolean metadata write.
Definition PointSet.cpp:371
void setIntAttribute(int index, const std::string &name, std::int64_t value)
Compatibility-only unchecked script setter; canonical code uses trySetIntAttribute.
Definition PointSet.cpp:358
float getBoundsMinY(int index) const
Return the local-space minimum Y bound.
Definition PointSet.cpp:217
ProcgenPoint & mutablePoint(std::size_t index)
Mutably access one existing point without changing row structure.
Definition PointSet.cpp:92
Result< void > trySetVectorAttribute(int index, const std::string &name, float x, float y, float z)
Canonical checked vector metadata write.
Definition PointSet.cpp:391
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:202
Result< void > assignPointIds(std::uint64_t namespaceId)
Fill zero identities deterministically and reject pre-existing duplicates.
Definition PointSet.cpp:310
bool hasFloatAttribute(int index, const std::string &name) const
True when float attribute.
Definition PointSet.cpp:347
float getPitch(int index) const
Return the point's local pitch in degrees.
Definition PointSet.cpp:171
void setBoolAttribute(int index, const std::string &name, bool value)
Compatibility-only unchecked script setter; canonical code uses trySetBoolAttribute.
Definition PointSet.cpp:378
std::uint64_t getPointId(int index) const
Return the stable point identity, or zero when it has not been assigned.
Definition PointSet.cpp:289
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:412
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:398
void setSteepness(int index, float steepness)
Set normalized surface steepness metadata in the inclusive range [0, 1].
Definition PointSet.cpp:264
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:382
int appendPoint(ProcgenPoint point)
Append a point with an empty attribute row and return its row index.
Definition PointSet.cpp:62
void setStringAttribute(int index, const std::string &name, const std::string &value)
Compatibility-only unchecked script setter; canonical code uses trySetStringAttribute.
Definition PointSet.cpp:428
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:402
Result< void > trySetIntAttribute(int index, const std::string &name, std::int64_t value)
Canonical checked signed integer metadata write.
Definition PointSet.cpp:351
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:362
float getSteepness(int index) const
Return normalized point steepness metadata.
Definition PointSet.cpp:268
Result< int > appendPointFrom(const PointSet &source, std::size_t sourceIndex)
Append a point and its attributes from another set.
Definition PointSet.cpp:69
void setRotation(int index, float pitch, float yaw, float roll)
Set the point's local Euler rotation in degrees.
Definition PointSet.cpp:163
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:221
Result< void > trySetFloatAttribute(int index, const std::string &name, float value)
Canonical checked float metadata write.
Definition PointSet.cpp:331
Result< void > tryDeleteAttribute(const std::string &name)
Delete one metadata column on this set.
Definition PointSet.cpp:445
void reserve(std::size_t count)
Reserve point storage without changing point or attribute row counts.
Definition PointSet.cpp:60
bool pointInPolygon(const Vec2 &p, const Polygon &poly)
Point-in-polygon test (ray casting; boundary counts as inside).
Definition UrbanGeometry.cpp:112
Definition EvpackPointGraphLoader.h:12
PointSet samplePolylinePoints(const PointSet &controlPoints, float spacing, uint32_t seed, float lateralJitter)
Sample polyline points.
Definition PointSet.cpp:757
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:891
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:1070
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:1047
PointSet unionPointSets(const PointSet &first, const PointSet &second)
Stable union by non-zero point id, with legacy position-and-seed fallback.
Definition PointSet.cpp:852
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:886
PointSet filterPointsByPolygon(const PointSet &input, const PointSet &polygon, bool invert)
Filter points by polygon.
Definition PointSet.cpp:638
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:606
PointSet filterPointSlope(const PointSet &input, float minDegrees, float maxDegrees)
Filter point slope.
Definition PointSet.cpp:621
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:1122
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:502
PointSet filterPointsBySplineDistance(const PointSet &input, const PointSet &controlPoints, float minDistance, float maxDistance)
Filter points by spline distance.
Definition PointSet.cpp:649
PointSet excludePointRadius(const PointSet &input, float x, float z, float radius)
Exclude point radius.
Definition PointSet.cpp:670
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:864
void appendPointRow(PointSet &output, const PointSet &input, std::size_t index)
Definition PointSet.cpp:56
PointSet mergePointSets(const PointSet &first, const PointSet &second)
Concatenate two attributed point collections while preserving order.
Definition PointSet.cpp:795
PointSet copyPointsToTargets(const PointSet &source, const PointSet &targets, bool inheritTargetAttributes)
Instantiate source points relative to targets in stable target-major order.
Definition PointSet.cpp:926
PointSet filterPointDensity(const PointSet &input, float minDensity, float maxDensity)
Filter point density.
Definition PointSet.cpp:597
std::uint64_t derivePointId(std::uint64_t namespaceId, std::uint64_t ordinal)
Deterministically derive a non-zero stable point identity.
Definition PointSet.cpp:469
PointSet selfPrunePoints(const PointSet &input, float radius)
Self prune points.
Definition PointSet.cpp:737
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:588
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:1089
PointSet densityCullPoints(const PointSet &input, uint32_t seed, float multiplier)
Deterministically keep points according to density and a root seed.
Definition PointSet.cpp:1058
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:875
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:459
PointSet jitterPointPositions(const PointSet &input, uint32_t seed, float amountX, float amountZ)
Jitter point positions.
Definition PointSet.cpp:724
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:1033
PointSet sampleGridPoints(int width, int depth, float spacing, uint32_t seed, float jitter)
Sample grid points.
Definition PointSet.cpp:480
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:682
@ 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