Help with larger amounts of Trackables

Rllulium

New Member
Reaction score
10
In an attempt to teach myself how to utilize trackables, I tried to fill a small area with trackables earlier. I thought I would then make a simple click to move test to see if it worked as I wanted. The problem that I have run into however, is that the game freezes when I try to to create more than roughly 60-100 trackables in one go. For reference, here is the code I am using; I was hoping that someone can point out something that I am doing wrong here:
JASS:
library TrackTest uses Trackable2 

globals
    private constant string  modelPath = "Doodads\\Terrain\\InvisiblePlatformSmall\\InvisiblePlatformSmall.mdl"
    private constant real    size      = 73.59
    private Trackable2 temp
endglobals

struct data
    //Set in Create function
    rect    zone
    real    minX
    real    maxX
    real    minY
    real    maxY
    //Used in methods
    boolean done     = false
    integer rowCount = 0
    real    x
    real    y
    
    method AddRow takes nothing returns nothing
        local integer i = 0
        set .y = .minY + size/2 + .rowCount*size
        loop
            set .x = .minX + size/2 + i*size
            set temp = Trackable2.create(modelPath, .x, .y, 0, 0)
            call temp.registerAnyClick(Click)
            call temp.registerAnyTrack(Track)
            set i = i + 1
        exitwhen i*size >= .maxX - .minX
        endloop
        set .rowCount = .rowCount + 1
        set .done = .rowCount*size >= .maxY - .minY
    endmethod
    
    method FillRect takes nothing returns nothing
        loop
            call .AddRow()
            call BJDebugMsg("Row Complete")
        exitwhen .done
        endloop
    endmethod
    
endstruct

public function Create takes rect area returns nothing
    local data new = data.create()
    set new.zone  = area
    set new.minX  = GetRectMinX(area)
    set new.maxX  = GetRectMaxX(area)
    set new.minY  = GetRectMinY(area)
    set new.maxY  = GetRectMaxY(area)
    call new.FillRect()
    call new.destroy()
endfunction

endlibrary
 

the Immortal

I know, I know...
Reaction score
51
Just a wild guess, but maybe hitting the OP limit? Try changing [ljass].AddRow()[/ljass] to [ljass].AddRow.execute()[/ljass] and see if there's a change.

If there IS a change but it still stops, then try splitting your functions to more parts, each using .execute()

If there ain't.. well.. I don't know, gonna eat! o_O
 

Azlier

Old World Ghost
Reaction score
461
Needs restructuring, although the current problems probably aren't causing the freeze.

Here's a rough layout.
JASS:
function CreateB takes nothing returns nothing
    //Loop through all x coordinates, creating all trackables with the given y
endfunction

function CreateA takes nothing returns nothing
    //Loop through all y coordinates, resetting the x global to the rect's minimum x and executing CreateB with the current y stored in a global in each iteration
endfunction

function Create takes rect r, other stuff returns nothing
    //Store the rect's data in globals, execute CreateA
endfunction
 

Rllulium

New Member
Reaction score
10
New Code:
JASS:
library TrackTest uses Trackable2 

globals
    private constant string  modelPath = "Doodads\\Terrain\\InvisiblePlatformSmall\\InvisiblePlatformSmall.mdl"
    private constant real    size      = 73.59
    private Trackable2 temp
endglobals

struct data
    //Set in Create function
    rect    zone
    real    minX
    real    maxX
    real    minY
    real    maxY
    //Used in methods
    integer rowCount = 0
    real    x
    real    y
    
    method FillRow takes nothing returns nothing
        set .x = .minX + size/2
        loop
            set .x = .x + size
            set temp = Trackable2.create(modelPath, .x, .y, 0, 0)
            call temp.registerAnyClick(Click)
            call temp.registerAnyTrack(Track)
        exitwhen .x >= .maxX
        endloop
    endmethod
    
    method FillRect takes nothing returns nothing
        set .y = .minY + size/2
        loop
            set .y = .y + size
            call FillRow()
        exitwhen .y >= .maxY
        endloop
    endmethod

endstruct

public function Create takes rect area returns nothing
    local data new = data.create()
    set new.zone  = area
    set new.minX  = GetRectMinX(area)
    set new.maxX  = GetRectMaxX(area)
    set new.minY  = GetRectMinY(area)
    set new.maxY  = GetRectMaxY(area)
    call new.FillRect()
    call new.destroy()
endfunction

endlibrary

I let the game remain frozen for a while, until I finally got an error message complaining about lack of storage. It seems that I need a way to let the game create one small rect at a time, waiting for the last one to finish before beginning to fill another. Which I actually should be able to make since I don't need to fill new rects on the fly ingame. Yet. I think.
 

Azlier

Old World Ghost
Reaction score
461
You forgot to, in the FillRect function, to reset x to it's minimum position with every iteration.
 

Azlier

Old World Ghost
Reaction score
461
I see. What rect are you trying to fill?

Also, you might want to throw in some .execute.
 

Rllulium

New Member
Reaction score
10
I see. What rect are you trying to fill?
Only small rects at a time right now, more than 500*500 crashes.
Also, you might want to throw in some .execute.
This did actually not make that much of difference. What however did make a very large difference was switching to normal Trackables instead of Trackable2s.

Something tells me that the the CreateTrackableZ-stuff should be optional. Creating and destroying an extra destructable with every trackable is probably a strain.
 

Azlier

Old World Ghost
Reaction score
461
The real bulk of operations coming from trackable2 has to do with how they are created. It's O(n) complexity. Normal trackables with some simple attachment are probably best.
 

Anachron

New Member
Reaction score
53
JASS:
    method FillRow takes nothing returns nothing
        set .x = .minX + size/2
        loop
            set .x = .x + size
            set temp = Trackable2.create(modelPath, .x, .y, 0, 0)
            call temp.registerAnyClick(Click)
            call temp.registerAnyTrack(Track)
        exitwhen .x >= .maxX
        endloop
    endmethod
    
    method FillRect takes nothing returns nothing
        set .y = .minY + size/2
        loop
            set .y = .y + size
            call FillRow()
        exitwhen .y >= .maxY
        endloop
    endmethod

You serious?

You should create one trackable which is 64*64 size big every 64px. Thats enough.
Something like this

JASS:
    globals
        private constant real       TILE_DIST = 64
    endglobals

    function createTracks takes rect r returns nothing
        local real xMin = GetRectMinX(r)
        local real yMin = GetRectMinY(r)
        local real xMax = GetRectMaxX(r)
        local real yMax = GetRectMaxY(r)
        local real x    = xMin
        local real y    = yMin
        local integer xTimes = R2I((xMax - xMin) / TILE_DIST)
        local integer yTimes = R2I((yMax - yMin) / TILE_DIST)
        local integer xCur = 0
        local integer yCur = 0
        
        loop
            exitwhen xCur >= xTimes
            
            set yCur = 0 
            set y = yMin
            loop
                exitwhen yCur >= yTimes
                
                set y = y + TILE_DIST
                // Create Trackable here on X and Y
                
                set yCur = yCur + 1
            endloop
            
            set x = x + TILE_DIST 
            set xCur = xCur + 1
        endloop
    endfunction
 

Rllulium

New Member
Reaction score
10
You serious?

You should create one trackable which is 64*64 size big every 64px. Thats enough.
Something like this

Now, I fail to see what you are trying to say here. I currently create one trackable of 74*74 every 74 units. What you are suggesting would require MORE trackables.
 

Anachron

New Member
Reaction score
53
Sorry, I missread it, its not 14, but 74. Sorry.

And did you try with my function? maybe you have an endless loop.
 

Rllulium

New Member
Reaction score
10
Sorry, I missread it, its not 14, but 74. Sorry.

And did you try with my function? maybe you have an endless loop.

Endless, nono. Covering a small area works like a charm. The problem is that I hit the operations limit very fast when I attempt to fill large rects.
 

Azlier

Old World Ghost
Reaction score
461
JASS:
library TrackTest uses Trackable2 

globals
    private constant string  modelPath = "Doodads\\Terrain\\InvisiblePlatformSmall\\InvisiblePlatformSmall.mdl"
    private constant real    size      = 73.59
    private Trackable2 temp
endglobals

struct data
    //Set in Create function
    rect    zone
    real    minX
    real    maxX
    real    minY
    real    maxY
    //Used in methods
    integer rowCount = 0
    real    x
    real    y
    
    method FillRow takes nothing returns nothing
        set .x = .minX + size/2
        loop
            set .x = .x + size
            set temp = Trackable2.create.execute(modelPath, .x, .y, 0, 0)
            call temp.registerAnyClick(Click)
            call temp.registerAnyTrack(Track)
        exitwhen .x >= .maxX
        endloop
    endmethod
    
    method FillRect takes nothing returns nothing
        set .y = .minY + size/2
        loop
            set .y = .y + size
            call FillRow.execute()
        exitwhen .y >= .maxY
        endloop
    endmethod

endstruct

public function Create takes rect area returns nothing
    local data new = data.create()
    set new.zone  = area
    set new.minX  = GetRectMinX(area)
    set new.maxX  = GetRectMaxX(area)
    set new.minY  = GetRectMinY(area)
    set new.maxY  = GetRectMaxY(area)
    call new.FillRect.execute()
    call new.destroy()
endfunction

endlibrary
 

Azlier

Old World Ghost
Reaction score
461
Yes, but why would you ever use something existing when you can reinvent the wheel repeatedly?
 

Rllulium

New Member
Reaction score
10
Here's something no one's mentioning.

Well, the whole point of this was for me to learn how to use trackables properly (as mentioned in the first post). One might argue that learning how to use a good system works just as well, but that's not really what I was searching for here.

For now, it seems that the usage of normal trackables with attachments is doing the job, so we may close this thread.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top