question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DrawNodeCircle has bug/redundancy. but it works.

See original GitHub issue

TrafficManagerTool.DrawNodeCircle has a bug. but the bug is in redundant code so it works.

//the debug logs does not exist in original code
public void DrawNodeCircle(RenderManager.CameraInfo cameraInfo,
                            ushort nodeId,
                            Color color,
                            bool alpha = false) {
    NetNode[] nodesBuffer = Singleton<NetManager>.instance.m_nodes.m_buffer;
    Debug.Log($"m_segment0={nodesBuffer[nodeId].m_segment0}"); 
    NetSegment segment =
        Singleton<NetManager>.instance.m_segments.m_buffer[ nodesBuffer[nodeId].m_segment0];//BUG!!!!!!!!!!!
    Debug.Log($"vectors = {segment.m_startDirection} {segment.m_endDirection}");

    Vector3 pos = nodesBuffer[nodeId].m_position;
    float terrainY = Singleton<TerrainManager>.instance.SampleDetailHeightSmooth(pos);
    if (terrainY > pos.y) {
        pos.y = terrainY;
    }

    Bezier3 bezier;
    bezier.a = pos;
    bezier.d = pos;

////Redundant!!!!!!  instead: *** bezier.a=bezier.b=bezier.c=bezier.d=pos ***
    NetSegment.CalculateMiddlePoints(
        bezier.a,
        segment.m_startDirection,
        bezier.d,
        segment.m_endDirection, 
        false,
        false,
        out bezier.b,
        out bezier.c);

    Debug.Log($"bezier = {bezier.a} {bezier.b} {bezier.c} {bezier.d}");


    DrawOverlayBezier(cameraInfo, bezier, color, alpha);
}

m_segment0 in the code above can be zero (screenshot 1). this is similar to #549. Fortunately here the code that utilizes m_segment0 is redundant at least to the best of my knowledge. In screenshot 2 m_segment0 is 0 and its directional vectors are subsequently zero as well. Nevertheless the final bezier result is accurate. screenshot 3 shows a valid m_segment0 will result in the same bezier result as invalid m_segment0.

Screenshot (46) Screenshot (71) Screenshot (70)

The call to CalculateMiddlePoints()

Why are we calling CalculateMiddlePoints on a single node anyway. node cannot collide with node?

Risk

  • If CalculateMiddlePoints is really redundant then we are getting away with the bug because the bug is in redundant part of the code. In future skylines upgrades this might result in null reference exceptions.
  • If I am missing something and there are circumstances in which CalculateMiddlePoints() is not redundant then we have a real bug.

Action

we do not need segment or a call to CalculateMiddlePoints (AFIK). Instead bezier.a=bezier.b=bezier.c=bezier.d=pos because its a simple node. DrawOverlayCircle(cameraInfo, color, pos, 20, alpha);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
kianzarrincommented, Nov 23, 2019

I think its better if we calculate the overlay circle radius as the average radius of all connected segments. Screenshot (91) Screenshot (90) Screenshot (89) Screenshot (88) Screenshot (92)

0reactions
kvakvscommented, Nov 19, 2019

You will get it assigned at some point, during the review of your pull request usually. On small tasks like this, especially reported by you and fixed by you, assigning yourself to it has no effect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circles in sociocracy: an effective organizational structure
It is a good idea to have some system that creates redundancy (e.g. a second person who knows how to fix the snowblower!)...
Read more >
adobe-illustrator-quiz.md
Select the circle and click the Draw Inside button on the toolbar before you brush. Add a fixed spacing value in the Scatter...
Read more >
What is a perfect circle?
A perfect circle is that circle which has same diameter everywhere inside the circle. Practically, its impossible to draw a perfect circle even...
Read more >
Crop an Image Into a Circle Shape (Easiest Method) - YouTube
This is a great tutorial for beginners. ... to a tutorial I create 2 years ago, which I think now uses a slower/more...
Read more >
Redundant DP Grounding
The configuration looks redundant but it isn't. The problem is something not shown in the drawing. Something not shown in most electrical ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found