#i can try but cause it is quite long ill

1 messages · Page 1 of 1 (latest)

honest wolf
#

Post it here so we don't completely clutter the channel

stoic iron
#

ah that is clever

#

this might take me while, as im figthing discords text limit, so im trying to shorten all the names in order to get it to all fit

honest wolf
#

You can post it here alternatively

lone saddle
#

no need to post as text

honest wolf
stoic iron
#

oh ok

lone saddle
#

or that

stoic iron
#

that should work?

#

i cut out the stuff around it, but those should be the 2 parts that matter

#

anything obviously wrong with the way i add to the lists?

honest wolf
#

I can't see anything on a quick glance, I guess your conditions aren't evaluating to true. Try just adding to a NativeList as a simple test

stoic iron
#

ok ill try that, and im pretty sure my conditions should be evaluating to true, cause when i test it with a nativearray it works perfectly

honest wolf
#

Hmm, odd.

stoic iron
#

only issue is that more than 1 collision can happen at a time, hence why im tryna switch to nativelists

lone saddle
#

your disposing your particleIds list in the job

stoic iron
#

i am?

lone saddle
#

very bottom

stoic iron
#

that isnt part of the job, that is the job runner though?

honest wolf
#

He's logging the Length before, I'm guessing it says 0

lone saddle
#

I'm not seeing a ParticleIds, just a _ParticleIds

lone saddle
#

get in the habit of doing m_privateField

#

or similar

stoic iron
#

is that the standerd for jobs, putting a m_ infront then?

honest wolf
#

The formatting is kind of messed up, ParticleIds is probably a field in this of the function he is calling

stoic iron
lone saddle
stoic iron
lone saddle
#

no, but putting a _ suggests it is

#

never do that

stoic iron
#

oh, i was just doing that cause i found it easier to understand my code, guessing im breaking some standerd i didnt know about, sorry lol

lone saddle
#

public somePublicField
private m_somePrivateField

stoic iron
#

ok got it

honest wolf
lone saddle
honest wolf
lone saddle
#

yeah np

stoic iron
#

ok thanks!

#

anyway, back to trying to get my code to work though lol

lone saddle
#

the length of the list wont change, unless you access the list after the job

#

so for example:

honest wolf
#

I don't think this is true, since NativeList holds a pointer to an UnsafeList

stoic iron
#

i just wanna foreach loop through the list, the length doesnt even really matter, i added that for debugging,

#

it is weird, cause a non job for loop with lists works, and a bursted job for loop with nativearrays works, but a bursted job for loop with nativelists just isnt

#

imma go have breakfast and think about this more, thanks for all the help everyone!

lone saddle
#

I think data is not being added at all

honest wolf
#

That's my guess too, but they mentioned it worked with a NativeArray

lone saddle
#

well, I think this is just user error and it can only really be identified with a quick and simple test adding to the list

#

@stoic iron

#

you're waiting for the job to finish, right?

honest wolf
#

He's calling Complete right after scheduling it

lone saddle
#

@stoic iron also you can use Debug.Log inside jobs fyi

stoic iron
#

you can? Cool!

lone saddle
#

I just highly advise you remove them after testing

stoic iron
#

ye

#

they can slow things down a ton

lone saddle
#

it slows it down by like 1000x

stoic iron
#

welp ive only got 70 thousand particles this job is for looping on, so it shouldnt be that bad

lone saddle
#

should take ~0.1ms ish

#

if it's parallel, even faster

stoic iron
#

huh ye my code is just broken, i guess when i was converting from native array to native list i must have bumped a for loop somewhere

#

welp thanks, im feeling like a real idiot lol

#

hmm my for loops look the same

#

weird

#

here is what my example non job for loop looks like, incase any obvious differences can be observed: ```cs
for (int i = 0; i < Container.SlotsUsed; i++)
{
int ContactIndex = Container.SBuf.ContactIndices.data[i];
uint Count = Container.SBuf.ContactCounts.data[ContactIndex];

        if (debug)
        {
            Debug.Log(ContactIndex);
            Debug.Log(Count);
        }

        for (uint c = 0; c < Count; c++)
        {
            Vector4 Velocity = Container.SBuf.ContactVelocities.data[ContactIndex * 6 + c];

            int ContactShapeId = (int)Velocity.w;

            if (ContactShapeId == ShapeIndex)
            {
                ParticleId = i;

                if (debug)
                {
                    Debug.Log("Collision!");
                }

                if (WhenToRunMethodOnCollision == WhenToRun.FixedUpdate)
                {
                    //MethodToRunOnDetectCollision?.Invoke(); deprecate
                }
                else
                {
                    RunMethod = true;
                }
            }
            else if (debug)
            {
                Debug.Log(ContactShapeId);
            }
        }
    }
#

as it looks the same to me...

#

perhaps my for loops aint job compatible (from testing it appears some for loops just cant be replicated in jobs, i learnt this the hard way with my emitters)