Skip to content

Exclude fluid particles from sensor scanning and reconnector targeting#507

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/update-sensor-processor-behavior
Draft

Exclude fluid particles from sensor scanning and reconnector targeting#507
Copilot wants to merge 3 commits intodevelopfrom
copilot/update-sensor-processor-behavior

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

Fluid particles (structure objects with numConnections == 0) should be invisible to sensors and reconnectors: sensors should penetrate them (no ray blocking), SensorMode_DetectStructure should not detect them, and ReconnectorMode_Structure should not connect to them.

Core changes

  • DensityMap (ObjectProcessor::fillDensityMap): Filter out fluid particles from the structure density map. This fixes both sensor ray blocking and structure detection in one place.
} else if (object->type == ObjectType_Structure && !object->isFluid()) {
    data.preprocessedSimulationData.densityMap.addStructureObject(object);
}
  • ReconnectorProcessor (tryCreateConnection): Skip fluid particles in structure reconnect mode.
if (otherObject->type != ObjectType_Structure || otherObject->isFluid()) {
    return;
}
  • CellProcessor (performEnergyFlow): Fix pre-existing bug where object->type was checked instead of connectedObject->type, causing cudaErrorIllegalAddress when Cell-to-Structure connections existed (e.g. via reconnector). The comment said "Skip if connected object is not a Cell" but the code checked the wrong variable.
// Before (bug): checked object instead of connectedObject
if (object->type != ObjectType_Cell) { continue; }

// After (fix): correctly checks the connected object
if (connectedObject->type != ObjectType_Cell) { continue; }

Test changes

  • Existing structure-mode tests for both ReconnectorTests and SensorTests updated to use connected structure pairs so they aren't classified as fluid
  • Three new tests added: structureMode_ignoreFluidParticle, detectStructure_ignoreFluidParticles, rayNotBlockedByFluidParticles
  • Set maxForce high in ReconnectorTests to prevent physics-related connection breaking during tests

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…nector

- DensityMap: Skip fluid particles (structure objects with no connections)
  in fillDensityMap so they don't contribute to structure density
- ReconnectorProcessor: Skip fluid particles in ReconnectorMode_Structure
  mode so reconnector cannot connect to them
- SensorProcessor: Benefits from density map fix - rays now penetrate
  fluid particles and DetectStructure mode ignores them
- Tests: Update existing tests to use connected structure objects,
  add new tests for fluid particle exclusion

Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
Copilot AI changed the title [WIP] Update SensorProcessor and ReconnectorProcessor to exclude fluid particles Exclude fluid particles from sensor scanning and reconnector targeting Mar 7, 2026
Copilot finished work on behalf of chrxh March 7, 2026 20:23
@chrxh
Copy link
Owner

chrxh commented Mar 9, 2026

@copilot fix failing tests

The energyFlow kernel at line 314 checked `object->type != ObjectType_Cell`
instead of `connectedObject->type != ObjectType_Cell`. Since `object` was
already verified to be a Cell at line 302, this check was always false and
never skipped non-Cell connected objects. When a reconnector connected a
Cell to a Structure, the kernel would access `connectedObject->typeData.cell`
on the Structure object, reading garbage union data (including invalid
creature pointers), causing cudaErrorIllegalAddress.

Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 9, 2026

@copilot fix failing tests

Fixed in c598df7. The root cause was a pre-existing bug in CellProcessor::performEnergyFlow at line 314 — it checked object->type != ObjectType_Cell instead of connectedObject->type != ObjectType_Cell. Since object was already verified as Cell at line 302, this check was always false and never skipped non-Cell connected objects. When a reconnector connected a Cell to a Structure, the kernel accessed connectedObject->typeData.cell on the Structure, reading garbage union data (invalid creature pointers), causing cudaErrorIllegalAddress. All 30 ReconnectorTests now pass with -d flag when run together.

Copilot finished work on behalf of chrxh March 9, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants