#i can try but cause it is quite long ill
1 messages · Page 1 of 1 (latest)
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
drag the file in
You can post it here alternatively
no need to post as text
oh ok
or that
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
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?
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
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
Hmm, odd.
only issue is that more than 1 collision can happen at a time, hence why im tryna switch to nativelists
your disposing your particleIds list in the job
i am?
very bottom
that isnt part of the job, that is the job runner though?
He's logging the Length before, I'm guessing it says 0
it does
I'm not seeing a ParticleIds, just a _ParticleIds
yes?
is that the standerd for jobs, putting a m_ infront then?
The formatting is kind of messed up, ParticleIds is probably a field in this of the function he is calling
ParticleIds is defined uptop somewhere, not in the function, as far as i know
for anything private. I had to actually triple check you were accessing the same field
i dont think it is private though, (is it?)
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
public somePublicField
private m_somePrivateField
ok got it
The C# standard is actually just _ but it depends on code style
yes, but I find it personally harder to read
I was just letting them know 🙂
yeah np
Here's some more info if you are interested https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions
the length of the list wont change, unless you access the list after the job
so for example:
I don't think this is true, since NativeList holds a pointer to an UnsafeList
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!
Yeah I was thinking of NativeArray
I think data is not being added at all
That's my guess too, but they mentioned it worked with a NativeArray
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?
He's calling Complete right after scheduling it
sure ill try this
yup
@stoic iron also you can use Debug.Log inside jobs fyi
you can? Cool!
I just highly advise you remove them after testing
it slows it down by like 1000x
welp ive only got 70 thousand particles this job is for looping on, so it shouldnt be that bad
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)