Skip to content

IgnoreLayers off by 1 error. #71

@KonstantinRudolph

Description

@KonstantinRudolph

Ignore the following see my second comment on the issue for the real problem:

The ignore layermask is off by one in OutlineRendererCollection.cs
in internal void Reset(bool includeInactive, int ignoreLayerMask)

when the gameObject-layer is shifted it's shifted 1 bit to much due to the shifted bit already starting at the first non-default layer (0)

Built-Ins:
Default: 0000
TransparentFX: 0001
IgnoreRaycast: 0010

Example Ignore-Layermask: 1110

gameObject on layer 0001: gameObject.layer == 1
current shiftcode:
((1 << renderer.gameObject.layer) & ignoreLayerMask) == 0)
=> 0001 << 1 produces 0010 expected is 0001
=> the condition fails although the gameobject is on the specified layer:
~~ => 0010 & 1110 == 0010 != 0000~~

correct would be:
((1 << (renderer.gameObject.layer -1)) & ignoreLayerMask) == 0)
=> 0001 << (1 - 1) produces 0001 expected is 0001
=> the condition succeeds for the same layer:
=> 0001 & 1110 == 0000 == 0000

Of course layer 0 must be handled differently (simply use 0 instead of shifting or limit the shift to be at least 0) to prevent: 1 << -1 (which equals 1 << 31 in c# for int), but that case is blocked by the use all if == 0 anyway

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions