Stencyl 3.4.0 is now out. Get it now!

Bug Issue: Very weird issue with adding an emptied list to another list


Pages: 1

UnusualCadence

  • Subscriber - Stencyl Studio
  • *
March 16, 2017, 11:53:16 am
Hello!

I have come across a weird bug that will take some explaining!

I doing real-time shadows using the following function to store an array of co-ordinates every frame. This particular function is getting the co-ordinates of the north side of a tile if it passes a certain check:



First I empty the 'ShadowsABCD' list, then get the co-ordinates for each point in a polygon, then add ShadowsABCD to a list that will then get drawn to the screen later on. This function is repeated as many times as there are tiles on screen that need a shadow drawn from it.

The issue I'm having is as follows: if I clear ShadowsABCD with 'empty list', the data does not seem to be fully cleared - when I trace the RayTraceList the values that have been added are the very first values added to ShadowsABCD over and over again.*

If I set ShadowsABCD to 'create new list' then this problem is fixed and the correct values are added to RayTraceList. However, this creates loads of garbage and frame spikes, as I'm 'newing' a list 100s of times per frame. Ouch!**

I am not sure if this is a haxe bug or what. I would love to fix it so I can reduce my framerate woes however!


*Additional weirdness: tracing the ShadowsABCD list shows that it's having the correct values added to it, but they revert to the wrong 'ghost' values when added to RayTraceList.

**I have also tried other things, such as replacing each value in ShadowsABCD rather than clearing it and adding, but the results are still the same!
« Last Edit: March 16, 2017, 12:13:16 pm by UnusualCadence »


rob1221

  • Master Stencyler
  • *
March 16, 2017, 12:07:21 pm
I'm guessing the last block should use "copy of ShadowABCD" so you can empty that list without affecting RayTraceList.
  • Status changed from New to Need Info


UnusualCadence

  • Subscriber - Stencyl Studio
  • *
March 16, 2017, 02:15:22 pm
Ooh ok, that worked! Thanks! Hopefully using the .copy does not create too much garbage collection. I could probably make some static arrays in code and get around the dynamic memory allocation that's going on, perhaps.


Issue updated by rob1221 - March 16, 2017, 02:57:52 pm
  • Status changed from Need Info to Closed


Pages: 1

Details

  • Reported
    March 16, 2017, 11:53:16 am
  • Updated
    March 16, 2017, 02:57:52 pm

  • View Status
    Public
  • Type
    Bug
  • Status
    Closed
  • Priority
    Normal
  • Version
    Stencyl 3.4
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Engine

Tags