#archived-dots

1 messages ยท Page 262 of 1

rustic rain
#

Yeah, but I don't have such menu

#

hold on, I'll restart Unity again

#

Nvm

rustic rain
#

yaaay, it finally works

rotund token
#

how convenient is it!

#

it will link your own new assemblies together as well

#

(dont judge the ui code too harshly, literally first thing i ever wrote in ui elements. was my learning case)

rustic rain
#

ok, normal renderpass works

#

now how to use it with collision texture

#

hm

#

Ok, I got it

#

was simpler than I expected kek

#

ok, it really is seems pretty simple

#

now, how do I get a color of pixel

#

of chosen viewport point?

rotund token
#

your texture size should match the dimensions of your resolution

rustic rain
#

I don't want it to be relevant

#

I do have a viewport point

#

upon clicking

#

I kind of want to just get that pixel disregarding what size texture is, based of viewport

rotund token
#

i don't really understand what your saying

#

your output texture neds to match screen resolution to have the right colors

rustic rain
#

Well, ok

#

How do I even get a texture tho

rotund token
#

does the tutorial not discuss the concept behind this?

remote crater
#

I successfully have .50 dots installed and my FPS issue is gone

#

That FPS issue crept in one of the september-nov unity upgrades

rustic rain
#

I wonder how I can make Material to have colour based off entity id

viral sonnet
#

I saw this a number of times now but I don't remember where. Certainly in the forum. I think a google search can lead you there.

rustic rain
#

I have been looking for this info for hour already

#

best I got: source of RenderObject feature kek

viral sonnet
#

keywords: "hybrid renderer color per entitiy" - hope you find what you're looking for

#

I've also read something about MaterialBlocks

rustic rain
#

nnnah, I'm not sure that's what I'm looking for

#

here's the thing

#

I need 2 renderers

#

1 for actual rendering

#

the other for collision rendering

#

where I render object's opaque basically

#

and then by reading pixel I determine what id of entity is inside that pixel

#

and I need to render 2nd without affecting first

#

Potentially maybe I just need another MeshRenderer for this

#

oh well, you can't add 2 MeshRenderers on same object

safe lintel
#

@rotund token is every folder inside that scripts folder also given an asmdef?

round narwhal
#

Hello everyone, I'm currently starting using DOTS and I cannot figure out how to create a Character Controller.
Can somebody give me a good example of what it can be ? (nb : it's for a FPS)

rustic rain
round narwhal
#

Thank you so much

rustic rain
#

but it's also outdated

#

haven't touched it since 0.50 release

viral sonnet
rustic rain
#

oj

#

oh

#

I see

#

it uses shader

#

Might be actually good, thanks

viral sonnet
#

np

rustic rain
hot basin
#

how can I use generics in job decryption/entity query?

#

i.e. I have interface with method .Evaluate() and 4 components that implements it

#

can I make generic job with <T> where T:Interface?

#

how to query for that?

viral sonnet
#

what's generic? the job or the data?

hot basin
#

job, data just inherits interface

viral sonnet
hot basin
#

but it uses generic system also so there is still one system per component

#

I would like to do something like this:

var GenericQuery = GetEntityQuery(ComponentType.ReadOnly<IMyInterface>());
viral sonnet
#

hm, maybe the polymorphic struct from PhilSA can help?

#

then phils solution will help. although it will source gen a switch

rotund token
#

I like to keep my library / game very modular and reusable

#

Heavy use of asmdef ensures no circular dependencies

rotund token
hot basin
#

it will?

rotund token
#

Sure why not?

#

You can use generics just not with entities.foreach/ijobentity (no code gen)

viral sonnet
#

@rotund token have you seen the post from dreaming in the events thread?

rotund token
#

nope, kind of stopped reading the thread ๐Ÿ˜…

#

why?

viral sonnet
#

Write key-value pairs to blocklists (NativeStream or similar) in parallel.
Copy the blocklist to a NativeList.
Sort the NativeList.
Allocate a second NativeList and store start offset and count pairs for matching keys
Iterate by key in parallel.

#

found that approach interesting

#

that's what he does in his animation package

#

certainly interesting when sorted by chunks especially

rotund token
#

well obviously now you need to implement it and compare ๐Ÿ˜„

viral sonnet
#

yeah ... ๐Ÿคฃ

#

I don't think it's that fast though. Too many steps involved. Kind of the overhead when you need determinism

rotund token
#

yeah he loves determinism

#

which if you need is obviously important

viral sonnet
#

I'm gonna take the interesting parts out of it. Namely, getting rid of the NMHM, utilizing a NativeStream/UnsafeParallelBlockList for fast writes, transform into a NativeList in single thread (no add problem) sort by chunk ptr (if possible) or indexInChunk. building the start offset and counts this can be parallelized. could be noiiice ๐Ÿ˜„

viral sonnet
#

Is the default NativeList.Sort any good? Sorting 500k takes 8ms

rotund token
#

for a sort that sounds reasonably fast

viral sonnet
#

Well ... then case closed ๐Ÿคฃ

#

shame though, sounded interesting without NMHM. maybe sorting by entity is a problem. The compare could certainly be written in a faster way

rotund token
#

you can pass in your own compare

#

but entity compare is already setup to only cmopare the index

#
        {
            return Index - other.Index;
        }
#

so not sure how you could make it faster since it already skips version so it's just an int compare

viral sonnet
#

ah thought it might compare version. never checked

viral sonnet
#

I'm just barely scratching the 60fps with using the new method of just writing to the NMHM key/values array

#

Pretty cool when this started with race conditions and Interlocked with 20ms. (Interlocked was the fast part, rest was slow)

pulsar jay
#

Anybody knows whats the state with reflection probes with URP and hybrid renderer v2? The reflection probes stop working when they are in a subscene

misty wedge
#

If I want to store a pointer to a struct on the managed heap, I would need to use GCHandle.Alloc(struct, GCHandleType.Pinned) first, then get the struct* or IntPtr to the struct, and dispose of the GCHandle when I don't need the pointer to the struct anymore. Is that right?

rotund token
#

yes

misty wedge
#

Is it possible to even get a pointer to the type of the struct (so for example Vector2*) outside of a fixed block?

#

Or do you need to use IntPtr

#

from e.g. GCHandle.AddrOfPinnedObject

coarse turtle
misty wedge
coarse turtle
#

yea

dense dew
#

You can also use UnsafeUtility to convert a struct to a pointer and back. It will free you from writing everything inside a fixed block and disposing of GCHandle before leaving the scope. You can store it as either void* or IntPtr, it doesn't affect performance. Just use whatever seems cleaner for you (void* requires to write a lot of 'unsafe' keywords, storing IntPtr requires converting it to void* before passing to methods).
https://docs.unity3d.com/ScriptReference/Unity.Collections.LowLevel.Unsafe.UnsafeUtility.html

pliant pike
#

Basic question but does anyone know if dots physics is simple and robust enough even for an idiot like me to use currently

viral sonnet
#

There's a bit of a learning curve and it depends on your workflow. If you use subscenes and Hybrid Renderer it's quite easy to setup

#

just looking at the physics example helped me quite a lot to understand how it's working

pliant pike
#

Ok thanks I guess I'll give it a try

calm edge
#

why do you need subscenes for physics?

misty wedge
#

Are there any restrictions on using generic structs inside components?

viral sonnet
hot basin
#

should ComponentTypeHandle be used with IJobEntityBatch? (i'm still on 0.17)

#

is GetComponentTypeHandle<>() or batchInChunk.GetNativeArray(); heavy or something?

#

do I make less allocations with this compared to entityQuery.ToComponentDataArray<>()?

coarse turtle
hot basin
#

so is this preferable way to iterate entities/entityqueries?

coarse turtle
#

I think with ToComponentDataArray, there is a memcpy involved somewhere in the function chain, but I forget exactly where

coarse turtle
hot basin
#

thanks!

#

is new NativeMultiHashMap<Entity, NativeArray<float>>() good or will it bite me later?

viral sonnet
#

makes it possible to use a ref then ref var position = ref translations[i];

#

There's not much difference apart from the small overhead of checks Unity is doing in GetNativeArray. I just like it more that way.

#

reason why I started this was that burst has a much easier time to vectorize pointers

#

don't ask me why

#

some methods I just could not get it to work even though the code did 100% the same thing

viral sonnet
#

there's also no reason NativeMultiHashMap<Entity, float>() will have a float[] for every key entity. That's what the multi implies

rotund token
hot basin
rotund token
#

did it run though?

hot basin
#

nope

viral sonnet
rotund token
#

im only saving translation/rotation/physicsvelocity in this particular demo

#

let me see what size it was

viral sonnet
#

is every frame saved or how does this work?

rotund token
#

yeah i was saving every frame for this

#

you could do whatever you want

#

for a 10min demo every frame is just easiest to implement

#

EntityManager.CreateEntity(typeof(Save));

#

is literally all you do to save a frame

viral sonnet
#

Braid done easy or what?

#

Or rather, how to code Braid in a one liner ๐Ÿ˜„

rotund token
#

cost of 24 frames in data

#

first frames clearly compressed better

#

probably a lot of 0 velocity

#

and all rotations would have been identical

#

so yeah im only compressing per component atm

#

if i do a final compression pass on the entire data it reduces size by another 20-25%

#

but im also only use lz4 so you could compress even better with something else

#

originally i compressed over whole set but thats 1 thread large time

viral sonnet
#

cool, maybe you can use the netcode delta compression.

rotund token
#

doing it per component means i can compress each component in parallel was much faster

rotund token
#

this is a save library not a rollback library

#

just thought i'd see how it did

#

makes an interesting/fun demo

viral sonnet
#

hehe, yeah. don't overdo it ๐Ÿ˜„

#

although, if you ever want to take it further that would be a sick feature

#

what are you planning with the save library? i.e asset store or not

rotund token
#

saving? ๐Ÿ˜„

#

oh you edited

#

not sure

#

it's pretty done i think

#

i'm just integrating with my demo game atm

#

to see pain points

#

the only thing i'm not sure about for usability is the prefab registration

#

if you're just saving subscenes / existing entities you don't need prefabs, it just gives everything a unique id and maps to it

#

but if you instantiate at runtime the system needs to find the prefab for it

#

which is handled, it searches for a matching prefab in the world

#

but how to uniquely ID these could be a bit awkward for a user

#

like if you have a prefab in 2 separate subscenes

#

they appear as the same thing

#

now personally in my project i have a single subscene with all my prefabs

#

then use weak asset references to avoid having duplicate prefabs

#

but do i want to ship or even enforce this on others

#

(it is how unity builds their demos as well though)

#

prefab per subscene is really bad memory use so its a preferred pattern i think though

viral sonnet
#

didn't unity add cross scene linking now?

rotund token
#

cross scene linking isn't so much the issue, it's if you link a prefab

#

each subscene gets its own SceneSectionData

#

which ties it to the subscene

viral sonnet
#

hm, yeah, I'd enforce saved entities in one subscene

#

maybe there's a good solution for it. I don't know but it sounds like quite the hassle

rotund token
#

i know my solution works really well but it requires users to use it

#

i was hoping to make this completely non-invasive

#

which apart from this it is

#

can drop it in any project and it should just work

viral sonnet
#

that's pretty awesome and honestly something I'd expect from a dots asset

rotund token
#

(well it'll just work saving translation, rotation, physics velocity)

#

if you want to save your own component need to add [Saved] to it

#

which is the point, it shouldn't save everything

viral sonnet
#

oh wow 0/10 too much work! /s

#

sounds all great, looking forward to it

#

I wrote a non-generic save system in 2019 (18?) and even though that was quite easy, lots of code was involved to add new comps and then instantiation. I would rather use something like this

rotund token
#

yeah this is the 3rd save system i've worked on

viral sonnet
#

does it use source gen?

misty wedge
rotund token
#

yes

rotund token
#

no code gen

#

i just use dynamictypehandle

#

with typeindex

viral sonnet
#

oh, and with that you get attributes?

misty wedge
#

How are you liking this approach compared to the second one? Since I also need to move away from SerializeWorld eventually ๐Ÿ˜ข

viral sonnet
#

or is this reflection based?

rotund token
viral sonnet
#

ah okay, was wondering how that would work

rotund token
#
            {
                if (type.TypeIndex == 0)
                {
                    continue;
                }

                if (type.Category == TypeManager.TypeCategory.ComponentData)
                {
                    if (type.Type.GetCustomAttribute(typeof(SaveAttribute)) != null)
                    {
                        this.AddComponentSaver(builder, type.TypeIndex);
                    }
                }
                else if (type.Category == TypeManager.TypeCategory.BufferData)
                {
                    if (type.Type.GetCustomAttribute(typeof(SaveAttribute)) != null)
                    {
                        this.AddBufferSaver(builder, type.TypeIndex);
                    }
                }
            }```
#
        {
            var stableTypeHash = TypeManager.GetTypeInfo(typeIndex).StableTypeHash;
            var saver = new ComponentDataSave(builder, stableTypeHash);
            this.savers.Add(saver.Key, saver);
        }```
#

just gets all components with the attribute from the typemanager

#

then from there it just uses dynamictypehandle to write out the data

#

went over it a bit more on the forums

misty wedge
#

And you migrate if any type hashes change?

viral sonnet
#

damn, sometimes burst needs like over a minute to compile -.-

#

not sure what that's about. it's sooo annoying that safety checks defaults to enabled and I have to turn it off every time

rotund token
misty wedge
#

I guess I will be going with something similar once I get around to it, this approach seems really solid

pliant pike
#

its really cool

rotund token
#

i wrote a couple of migrations depending on how comfortable user is with pointers (high performance) and just easy

pliant pike
#

it seems like its much simpler to do something like this in dots than monobehaviour

rotund token
#
    public class TestComponentForMigrationMigrator : ComponentDataMigrate<TestComponentForMigrationMigrator.Before, TestComponentForMigrationMigrator.After>
    {
        public override ulong From => 1392796844747678277;
        public override ulong To => 17841778420484547873;
    
        protected override void Migrate(ref After newComponent, in Before oldComponent)
        {
            newComponent.Value = oldComponent.value;
            newComponent.NewValue = 5;
        }
    
        public struct Before { public int value; }
        public struct After { public int Value; public int NewValue; }
    }```
is like the easy version for users
#

i wrote a typedatabase to record old types

#

so you can get info easily

#

so you can find your old components rather than just seeing a magic number

misty wedge
#

Awesome. Let me know if you ever make it public or anything, I'd happily pay for something like this

viral sonnet
pliant pike
#

yeah just having to add saved to the data is just ridiculously easy on the users end

viral sonnet
#

it is and while this could be done with monobehaviours, the strict DOD limitations are hardly followed in OOP approaches so it all gets kind of messy

pliant pike
#

it kind of amazes dots hasn't taken off years ago

#

dots seems way simpler and more logical to me than oop

hot basin
#

oop is to big in the industry

#

outside of game developement

#

to be used in broader context here

#

or I should say was

viral sonnet
#

kind of crazy, creating spellCreateData and directly executing the spell calculations -> 11.2ms writing the spellCreateData and then calculating it. 8.0ms + 6.85ms. for some reason one thread is completely idle. nativeThreadIndex is weird...

pliant pike
#

I know there is a few obscure devs that use it though

hot basin
#

it's easier for companies to find someone with experience with oop than dod

#

so oop is economically more viable

viral sonnet
#

I dunno, we used MVC around 2008 for web development and that was already 100 times better. With long running engines you have the problem of technical debt so moving away from OOP is hard

#

And I also don't know what makes someone "good" in OOP. The spaghettis I've seen ... /shudder I consider someone good when he doesn't write endless amounts of spaghetti code. If he's capable of that, he's also capable of DOD

#

but let's face it. most programmers suck and should do something else

pliant pike
#

yeah from what I've seen most oop code is about obfuscating data and making things look more complicated than they are

viral sonnet
#

to their defense, corporate loves OOP. it's like the dream came true. have 100 people work on 100 different things and it all comes together. but yeah, that's what it is. a dream. the reality is that you have people just dedicated to clean up the mess.

#

when you can throw 100s of people at something management just doesn't care much. they rather see progress

pliant pike
#

I bet progress would be faster if they used something like dots though

viral sonnet
#

and progress can be pretty great in OOP. just code something. others will figure it out or write endless amounts of wrappers around it

misty wedge
#

I think having 100 people work on 100 separate things and having it come together at the end is hard no matter what you do

viral sonnet
#

exactly, it's impossible in my opinion. a few core people have to work on the core. when that's solid, and this takes time it gets more manageable

misty wedge
#

I think it depends very much on the type of application. With people moving away from monolithic applications in spaces like web development cooperation becomes easier as long as your interfaces are well defined

viral sonnet
#

tbh enterprise code today is pretty solid. it's not the mess that it was years ago

misty wedge
#

I think you will have very different experiences based on the company ๐Ÿ˜…

viral sonnet
#

DI and proper patterns that proofed solid have streamlined the process somewhat

#

that's for sure ๐Ÿ˜„

#

enterprise code as in, coding style.

viral sonnet
#

the nativelist block reserve is really one of the sickest optimizations I've done. Can't thank you enough @rotund token ๐Ÿ˜„ It even blows NativeStream and UnsafeParallelBlockList out of the water. As it's pre allocated it has nearly 0 impact

rotund token
#

yep

#

if you know your upper limit and code can handle allocating in chunks its about as fast as it can get

viral sonnet
#

I still have to figure out how I can handle the capacity in a better way. Right now I'm allocating much more than I need. I've casters, triggers and buffs that potentially calculate spells but all are unknown until it happens.

#

although this is much more of a problem in the stress tests I'm doing. In real scenarios it shouldn't be possible to hit the limit

#

uhm ScheduleParallel(testList.Length, 64, Dependency) how does this work in an IJobFor? There's only public void Execute(int index) - no inner loop count

#

guess I'm looking for IJobParallelForBatch

rotund token
#

inner is how the the scheduler works

#

it'll work on 64 elements per thread before trying to find a new range

#

its purely an optimization value

viral sonnet
#
6.04ms -> spellcastjob + write to list
7.32ms -> calc from list

instant calc method:
5.27ms -> spellcastjob
11.14ms -> spellcastjob + calc -> 5,87ms for calc``` this confuses me right now
#

calculating from the list is 1.45ms slower. I'd have expected it to be on par, maybe somewhat slower but not that much

#

aha! my block reserve size was too small. 4.58ms now. faster than the previous. noiiiice

#

i love when i lose some time but gain more ๐Ÿ˜„

worldly isle
#

I have been trying to find this but don't see it anywhere is there a way to say have a system with a group that have all the entities that have had a particular component added since last run. I don't know if I said this well or not...

#

Anyone have any ideas about this?

haughty rampart
muted field
#

can jobs read data from static lists/arrays assuming it is only allow to read from them and not write ?

#

or do they also have to be native containers

rotund token
#

only static readonly

#

burst supports something like

#

public static readonly int[] Indices = new int[] {1,2,34,5};

muted field
#

thats fine

#

as long as i can read it its all i need

#

thanks!

covert patrol
#

which unity version is stable for the dots and some child packages not appering in 2021 i decided to learn dots which version should i use ?

muted field
rotund token
#

probably not

worldly isle
haughty rampart
covert patrol
haughty rampart
covert patrol
#

thanks in some videos i see in unity registery so i confues i will add on git thanks

muted field
#

๐Ÿ˜ฆ

rotund token
#

i play graphs back in burst jobs

#

you dont need references to make a graph

muted field
#

well my node is a class and my edges are a class too

#

(pathfinding stuff)

rotund token
#

well yeah that wont work in a job

muted field
#

you saying i should use structs for them ?

rotund token
#

need to build it from structs and pointers

muted field
#

pointers ? so ill have to use unsafe c# to setup my graph data?

haughty rampart
#

'unsafe'

muted field
#

yes the context unsafe ๐Ÿ˜›

rustic rain
#

this is so annoying

#

some kind of compile error

#

in VS

#

in source of entities

rotund token
#

what version of vs

rustic rain
#

2022

rotund token
#

think i saw a few of these when i upgraded (in rider)

#

had to clear library to get rid of them

#

haven't come back though

haughty rampart
#

just wait for the release instead of fiddling with the code yourself tbh

rotund token
#

release of what?

haughty rampart
#

entities

rotund token
#

if you're waiting for 1.0 that's going to be a while...

#

any this issue happens just in the default packages folder nothing to do with changing the package

haughty rampart
#

a few more weeks for 0.51 for 2021 ....and 1 year for 1.0 2022

rustic rain
#

and what am I supposed to do now

#

kek

haughty rampart
#

not use 2022

rustic rain
#

uhm

rotund token
#

thats his version of visual studios...

#

not unity

haughty rampart
#

ohhh

rustic rain
#

yeah

haughty rampart
#

strange then

#

haven't experienced any issues with that

hot basin
#

Can someone explain to my why this job can't be vectorized?

Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: EntityQueryManager.cs:752:0: loop not vectorized: loop control flow is not understood by vectorizer
[BurstCompile]
    public struct EvaluateAxisQuadratic : IJobEntityBatch
    {
        public ComponentTypeHandle<Axis> AxisTypeHandle;

        public void Execute(ArchetypeChunk batchInChunk, int batchIndex)
        {
            var axes = batchInChunk.GetNativeArray(AxisTypeHandle);

            for (var i = 0; i < batchInChunk.Count; i++)
            {
                var axis = axes[i];
                axis.value = (axis.m * math.pow(axis.input - axis.c, axis.k)) + axis.b;
                axes[i] = axis;
            }
        }
    }
#

is this because of floats? (all fields of Axis are of float type)

rotund token
#

what does the burst code look like

#

to start with

#

batchInChunk.Count

#

try use axes.Length

#

ArchetypeChunk .cs
public int Count => math.select(m_BatchEntityCount, m_Chunk->Count, m_BatchEntityCount == kUseChunkCount && m_Chunk != null);

rotund token
rustic rain
#

bruh, this error remains

#

I can't use debugging because of it

#

since VS can't build it

#

I even tried 2019 VS

rotund token
#

you shouldn't have to build to attach a debugger

haughty rampart
#

Try rei stalling entities

rotund token
#

do you have a custom version of entities in your packages folder?

rustic rain
#

I tried reimport all

#

several times

rotund token
#

or is this in the package cache

#

did you delete your library or just do reimport all

rustic rain
#

all installed through dependency on hybrid renderer

rustic rain
haughty rampart
#

Just create a new project and move your assets over

rotund token
rustic rain
#

all right

hot basin
rotund token
#

yeah this has nothing to do with your loop

#

i have 15 of these for a job with 1 loop ^_^"

#

honestly the llvm ir optimisation diagnostics tab is pretty useless

#

i never use it

hot basin
rotund token
#

why wouldn't it?

#

what are you proposing instead?

hot basin
#

get array outside and use IJobParallelFor instead

haughty rampart
#

Why are you not upgrading?

rotund token
rustic rain
#

nnnnope, deleting library didn't help

hot basin
haughty rampart
hot basin
rotund token
#

yes

#

go look at the actual generated code

haughty rampart
#

Otherwise you won't even be able to upgrade with 1.0

hot basin
haughty rampart
hot basin
#

i can wait until 0.51

rotund token
#
            {
                public float m;
                public float c;
                public float k;
                public float b;
                public Unity.Mathematics.float3 input;
                public Unity.Mathematics.float3 value;
            }```
assuming this was your struct
#

not sure if they were float or float3

rustic rain
#

Any other ideas how can I fix it?

hot basin
rotund token
haughty rampart
#

Ok

hot basin
rotund token
#

makes sense

#

not sure why i thought they were float3

hot basin
rotund token
#

not really it's all scalar

rustic rain
#

I guess I'll try rider xD

rotund token
#

student? it's free!

#

that's how they get you

#

next minute asking employer for it

rustic rain
rotund token
#

no sneaky email hanging around?! ๐Ÿ˜ฆ

#

managed to use mine for like an extra 3 years after i finished uni

#

this was quite a while ago now though

#

(not for rider didnt exist)

hot basin
rustic rain
#

no email in my uni at all xD

rotund token
#

breaking it down

#

a quick google seems to imply yes it doesn't exist

#

if you konw your x,y are both positive you can use
exp(y*log(x))

#

doing this definitely simds the whole thing

#

like seriously the entire thing

#

ties all the way back into the schedule job code

hot basin
#

but I don't have y?

rotund token
#

pow(x,y)

hot basin
#

i'm calculating y there

#

oh that y

rotund token
#

dont actually know if this is faster though

#

you'll have to test it

hot basin
#

what assembly shows when it vectorize?

rotund token
#

you want to see lots of purple!

#

ps for wide
ss for scalar

#

go watch the burst talk on it

#

anyway enough optimising someone else code, need to optimise my own

hot basin
#

like this?

#

still ss

rotund token
#

cant do everything wide

#

also

#

if a loop has to be vectorized

#

you can use

#

Loop.ExpectVectorized()

#

UNITY_BURST_EXPERIMENTAL_LOOP_INTRINSICS

#

and it'll be a compile error if a loop isn't vectorized

#

very handy if you vectorize something to protect it from breaking in future

hot basin
#

ok thanks a lot!

rotund token
#

it's a bit finicky though

hot basin
#

there is also possibility to manually vectorise this with float4 everywhere

rotund token
#

often the only way to reliable get this to work

hot basin
#

but I wonder if I can easily reinterpret Axis to Axis4

rotund token
#

you know what, it's time to test IEnableableComponent, see what's broken

#

when i was looking at burst for your code it was doing a proper check for this

dull copper
#

Unity is apparently renaming the hybrid renderer to com.unity.entities.graphics

#

I do welcome this change as it's now more obvious what it's for

full epoch
#

I updated dots related packages to the newest versions(0.50.1 entities etc) - everything works except mathematics 1.2.6 which should stay the old version (1.2.5 works for me)

robust scaffold
robust scaffold
#

"upgrade" to 2022.2 alpha... and burst crashes. FUUUUUUCK

#

thats what I get for trying to use Unity's automated upgrader. pain

dull copper
#

or.. maybe not use alpha

#

is current dots even compatible with it?

#

(haven't followed this part)

#

burst itself should work though

robust scaffold
dull copper
#

having burst itself installed on latest alpha doesn't crash things here... so much be some script on your end that triggers it

#

why do you assume it's the auto-upgrader that messed it up? it's supposed to just adjust things for the changed API so things wouldn't break

#

if it straight up crashes, I'd try wiping the library folder in case there's some cached stuff from previous version that's incompatible (this wouldn't be the first time).. and then start looking at the scripts using Burst that might break it so you can pinpoint the source of the issue

robust scaffold
dull copper
#

I can't say I've had similar experience on my end, never had issues with the autoupgrade scripts myself. of course this doesn't mean it wouldn't break for others.. maybe you've been just very unlucky for it to break on specific things you use it for

robust scaffold
#

Fuck. I think I narrowed down the crashing to somewhere in my shader stack. This is gonna be pain.

remote crater
#

What is the best way to do an array in a ComponentData struct?

#

I'm saying scew it and just making int a1;int a2;int a3; etc for now

#

I think I had this question for close to a year now... No one here or on the forums had a good answer that worked. Kinda silly, but its starting to hit my core architecture's foundation.

#

If I don't get help now, its going to be a costly refactor in the future.

#

I can get my game working, but I'm a fan of eloquent and beautiful looking code especially when it impacts functionality.

whole gyro
#

Do you need it to be in an IComponentData struct? If not, dynamic buffer is the recommended approach for having an "array" associated with an entity.

muted field
#

why cant jobs use reference types but regular threading can, whats the difference between jobs and threads?

remote crater
#

Thanks Graviton, I think you helped me, it's not pretty, but better than nothing.

whole gyro
#

Another option is to use a blob if the arrays are static and set up at conversion time

#

But dynamic buffers are definitely the easiest/cleanest of the 3 to use.

viral sonnet
rotund token
#

anyone know much about IJobBurstSchedulable

#

and any reason you wouldn't use this over IJob?

#

as far as I can tell it's IJob that can be schedule from burst code (ISystem)

#

which leads me to the question of there must be a difference otherwise why not just rewrite the IJob scheduler to support burst

viral sonnet
#

what information do we have about it? I just read it's removed in 0.50.

#

scheduling jobs from jobs was on my wish list. never heard of it before

#

haha, Unity is calling it 0.5 ... whoops ๐Ÿ˜„

rotund token
#

well i was not expecting it to be faster for me to write 10mill elements to a hashmap in single thread vs 24 threads
that locking kills it

#

in other news, wrote a new container NativeLookup which is basically just an alternate NativeMultiHashMap without the ability to remove elements and all my high performance batch operations built in

upper tiger
#
 CollisionFilter Filter = new CollisionFilter
                    {
                        BelongsTo = 0xffffffff,
                        CollidesWith = 1u << 3 | 1u << 5, // collide with terrain and world bounds
                        GroupIndex = 0
                    };

                    var pointDistanceInput = new PointDistanceInput
                    {
                        Position = localToWorlds[i].Position,
                        MaxDistance =  20f,
                        Filter = Filter
                    };

                    // this should get the closest hit
                    if (world.CalculateDistance(pointDistanceInput, out closestHit))
                    {
                          //... 
                    }                   

I cant seem to get my collision filter to collide with a layer 3 physics shape. It can get a distance hit with a simple cube just fine, but a complex mesh it never seems to trigger.

#

the "Belongs To" is mixed because I put it on both layer 3 and 5 out of frustration but didnt work

#

both the mesh object and the simple cube physics shape object have convert to entity with inject

upper tiger
#

I figured out the problem but not sure why. If you do calculate distance from within a mesh collider box, other colliders dont seem to register until you are out of the bounds of that collider

#

I want my objects to stay within the box but also avoid other things that are also in the box.

rotund token
#

not sure if related but from memory there is 1 big difference between unity regular physics (physx) and unity.physics and that is how collisions or at least raycasts work if you're within a collider

#

1 of them raycasts hit the other doesn't

rustic rain
#

thanks to your tips, guys, I am having a good progress

#

this is entityIdColor screenshot

#

certain problem tho is that it's not precise for some reason

#

entities are indeed rendered correctly, but left entity won't be calculated correctly

rotund token
#

Oh that's looking promising

#

If you're lookup is wrong from memory one issue is linear vs gamma

rustic rain
#

hm

#

thing is

#

look up is correct for some entities

#

but not for another

rotund token
#

Hmm

rustic rain
#

and also it gets ruined if I move my camera

#

I do recalculate camera matrix and etc

#

on each snapshot

#

hhhhmmm

#

I think I got the reason

#

I mixed colour bytes

#

and I can see jpeg like distortion

#

wait a secon

#

lol

#

this is so funny

#

I think I am reading pixel upside down

#

๐Ÿคก

rotund token
#

Of yeah that's a common issue

rustic rain
#

sooo

#

to fix it

#

I just do resolution - positionOfPixel?

#

already testing

#

kek

rotund token
#

Yeah usually just flip the y

rustic rain
#

yyyep

#

it's good now

#

oh man, feels so good

#

Thank you so much

rotund token
#

Where'd you end up injecting this?

rustic rain
#

I pretty much copied that tool that other guy sent

rotund token
#

But yeah it's a great technique

rustic rain
#

overall looks like this

rotund token
#

It's also nice how accurate the picking is vs colliders

rotund token
#

Nice

rustic rain
#

I guess the only problem

#

it doesn't render sprites

#

since they don't have RenderMesh component

rotund token
#

Can add them in a separate loop though?

rustic rain
#

Probably

karmic basin
#

Nice ๐Ÿ‘

remote crater
#

Can you test if an entity has an IBufferElementData attached?

#

I'm able to use them, but if I try and access it form an entity that does not have one attached, it errors out: ArgumentException: A component with type:TriggerIgnoreBufferElement [Buffer] has not been added to the entity.

#

My code: DynamicBuffer<TriggerIgnoreBufferElement> beA = World.DefaultGameObjectInjectionWorld.EntityManager.GetBufferfrome <TriggerIgnoreBufferElement>(entityA);

rotund token
#

you can use has component

remote crater
#

oh thanks tert

#

you rool

#

Worked like a charm, now I can use arrays properly with some semblance of a solid architecture.

viral sonnet
rotund token
#

yeah pretty much

#

just interesting that single thread is faster than multi thread

#

for normal hash map

viral sonnet
#

dat interlocked stall. same problem with nativeList

rotund token
#

too many threads and interlock destroys me

#

that said, i'm still using interlocked for my implementation

viral sonnet
#

do you convert the keys/values from the hashmap to a list and reserve?

rotund token
#
            [NoAlias] this NativeHashMap<TKey, TValue>.ParallelWriter hashMap,
            [NoAlias] TKey* keys,
            [NoAlias] TValue* values,
            int length)
            where TKey : unmanaged, IEquatable<TKey>
            where TValue : unmanaged
        {
            var writer = hashMap.m_Writer;
            var data = writer.m_Buffer;

            var newLength = Interlocked.Add(ref data->allocatedIndexLength, length);
            var oldLength = newLength - length;

            var keyPtr = ((TKey*)data->keys) + oldLength;
            var valuePtr = ((TValue*)data->values) + oldLength;

            UnsafeUtility.MemCpy(keyPtr, keys, length * UnsafeUtility.SizeOf<TKey>());
            UnsafeUtility.MemCpy(valuePtr, values, length * UnsafeUtility.SizeOf<TValue>());

            var buckets = (int*)data->buckets;
            var nextPtrs = ((int*)data->next) + oldLength;

            for (var idx = 0; idx < length; idx++)
            {
                var hash = keys[idx].GetHashCode() & data->bucketCapacityMask;
                var index = oldLength + idx;
                var next = Interlocked.Exchange(ref UnsafeUtility.ArrayElementAsRef<int>(buckets, hash), index);
                nextPtrs[idx] = next;
            }
        }```
#

i added an AddBatch method for ParallelWriter

#

which is pretty much what my above NativeLookup is using

viral sonnet
#

mh, interesting. you can get rid of the memcpy with the method I suggested a few days ago

rotund token
#

i don't want to get rid of the memcpy though

viral sonnet
#

why not? ๐Ÿ™‚

rotund token
#

because the memory i'm writing from is not safe to keep a reference to

#

because chunks can change while my jobs are running

viral sonnet
#

i mean, it would be another extension method. this one is perfectly fine. what's the data type for the keys/values you use? temp allocated nativeList?

rotund token
#

keys/values is a pointer to <entity,components> in chunks

#

i'm just direct copying entity data in

#

per chunk

viral sonnet
#

ah I see, ok, now I got you why you are not doing it ๐Ÿ˜„

#

that's clever ๐Ÿ™‚

#

yeah, seems like the most convenient way and fastest way to index chunk data. pretty cool

rotund token
#

I used to have this a few years ago and I missed it so finally adding it back is good

#

I can now just select entities with most, such a nice simple concept

rustic rain
#

Can anyone remind me how to get component data so I can use it in ForEach loop?

shell berry
viral sonnet
#

what's nice about it, is that it doesn't need physics, colliders or raycasts.

rustic rain
#

yyyep

#

camera based selection

rotund token
viral sonnet
#

you always go one step beyond ๐Ÿ™‚

#

any idea to write better profileMarker code? I hate this

rotund token
#

i always use Auto personally - having to do an end is horrid

#

but i never use that many markers

#

1 per method max

rotund token
#

Something like

            {
                var mesh = chunk.GetSharedComponentData(renderMeshType, this.EntityManager);
                var entities = chunk.GetNativeArray(entityType);
                var localToWorlds = chunk.GetNativeArray(localToWorldType);

                this.matrices.Clear();
                this.colors.Clear();
                propertyBlock.Clear();

                foreach (var entity in entities)
                {
                    var color = IndexToColor(entity.Index);
                    map.Add(color, entity);
                    this.colors.Add(color);
                }

                propertyBlock.SetVectorArray(colorID, this.colors);

                this.matrices.AddRange(localToWorlds.Reinterpret<Matrix4x4>());
                var matrixArray = NoAllocHelpers.ExtractArrayFromListT(this.matrices);

                cmd.DrawMeshInstanced(mesh.mesh, mesh.subMesh, mat, 0, matrixArray, this.matrices.Count, propertyBlock);
            }```
viral sonnet
#

yep, I'm using Auto now too. Much cleaner now.

#

I'm always amazed how much broad changes you can make in DOD. Like enabling multiple code paths for one feature just because the paths already exist. In OOP that was hardly doable.

muted field
#

so with dots everything has to be value type not reference type but what if you need a struct with an array of points like a polygon shape with vertices

#

since arrays are reference types how can i represent it in a struct

#

plus i need an array of each polygon so i need up with array of polygons which have array of vertices

#

so how can i setup the data like that using structs ๐Ÿค”

viral sonnet
#

first of all, no, not everything has to be a value type. it can be pointer too. second, where do you want to store this data?

muted field
#

i need to keep a persistent list of all my polygons

#

but im doing jobs on all the data

#

so i cant use classes

viral sonnet
#

You can keep that data in a NativeList/NativeArray in one of your systems then

muted field
#

i dont seem to have native list in my options only native array

#

is it in a separate package ?

viral sonnet
#

it's all in Unity.Collections

muted field
#

its not for me

viral sonnet
muted field
#

let me double check - should have since native array has worked fine

#

ah okay so native array is built in the rest is in a package

#

that explains it

viral sonnet
#

if you don't have burst installed, also add that ๐Ÿ™‚

muted field
#

so its allowed to have native lists in a struct then

#

does that mean when you pass a native list (or array) in methods the whole collection is copied ?

#

so i need to use ref every time

viral sonnet
#

while you can use ref, the only thing that is copied is the pointer, length and capacity + some safety checks

muted field
#

oh

viral sonnet
#

the actual data is in unmanaged memory

rotund token
#

native containers wrap a pointer so effectively behave like a class not a struct

#

unsafe containers don't do this though and act like a struct

muted field
#

i see. interesting new way to think about code design compared to my old oop ways

viral sonnet
#

start with some easy burst examples and enjoy the speed ๐Ÿ™‚

rotund token
#

got back from shops, did 1 more quick pass on this entity selection bursting the setup
@rustic rain if performance is something you need have a look at this - bursted setup + mesh instancing

#

you won't have access to like half the extensions though by default ๐Ÿคฃ
e.g. AddRangeNative, NoAllocHelpers.ExtractArrayFromListT, AddBatchUnsafe

muted field
rotund token
#

you can't store a native container inside another native container

#

you can store unsafe containers inside native containers just know by default burst will always compile this the 'slow' way (still fast)

muted field
#

oh jeez this is getting complicated quickly

rotund token
#

also there are Fixed* containers where you don't have to worry about memory

#

FixedList64Bytes<> for example

#

which is really just a chunk of fixed memory that behaves like a list

muted field
#

why wont they allow a container of structs with containers =/

viral sonnet
#

what's your code? I thought you just have a struct with a NativeList/Array inside it? that should be fine

muted field
#
    public readonly struct Area
    {
        private readonly NativeArray<float2> vertices;
        public readonly NativeArray<float2> Vertices => vertices;
        public Area(in NativeArray<float2> vertices)
        {
            this.vertices = vertices;
        }
    }

    private NativeList<Area> _areas = new NativeList<Area>(); // denied
viral sonnet
#

ah, yeah that won't work

muted field
#

what would be the right way to setup my data for this ?

viral sonnet
#

the quickest I could think of is with pointers and manual allocation/deallocation. another is to flatten the whole struct or use 3 flat arrays and get rid of the area struct alltogether

rotund token
#

need to know what your actual problem is

muted field
#

my goal is to check if areas overlap another area

#

planning to use parallelfor job for it

rotund token
#

how large are your polygons

#

number of points

muted field
#

some could have 1000+

rotund token
#

yeah ok if so large/variable you probably need unsafe container or pointers

#

i.e. just change your NativeArray<float2> vertices to UnsafeList<float2>

#

just remember unsafelist behaviours like a struct and needs write back

muted field
#

what do you mean by write back

viral sonnet
#
private NativeList<int> verticesLengths``` one way to flatten. you'd have a linear list of all the areas and their vertices and another array that has the length of each area
rotund token
#
        {
            var nativeList = new NativeList<int>(0, Allocator.Temp);
            var unsafeList = new UnsafeList<int>(0, Allocator.Temp);
            
            Add(nativeList);
            Add(unsafeList);
            
            Debug.Log(nativeList.Length); // 1
            Debug.Log(unsafeList.Length); // 0
        }

        private void Add(UnsafeList<int> list)
        {
            list.Add(1);
        }

        private void Add(NativeList<int> list)
        {
            list.Add(1);
        }```
rotund token
#

i'd even consider vertices instead being 2 values, start + length

muted field
rotund token
#
        {
            var i = 0;
            Add(i);
            Debug.Log(i); // 0
        }

        public void Add(int i)
        {
            i += 1;
        }
muted field
rotund token
#

for the same reason this is 0

muted field
#

so then how do you actually add to an unsafe list if .Add(1) doesn't actually add to its length

rotund token
#

pass it by ref

#

and write it back if it's stored in a native container

viral sonnet
#

or return it in the method but ref is better

rotund token
#

yeah or that

#

just imagine it's an int

muted field
#

so just do list.Add(ref number)

rotund token
#

no

#
        {
            list.Add(1);
        }```
#

the container has to be by ref

muted field
#

oh so unsafe containers do not get passed like references like native containers do

#

aka they dont wrap a pointer to it

rotund token
#
            var list = lists[0];
            list.Add(1);
            lists[0] = list;```
#

just remember this as well

#

usually i wouldn't even bring up pointers/unsafe containers for someone newish to dots unless they had a solid c/c++ background

rotund token
muted field
#

got to learn it eventually ๐Ÿ˜›

rotund token
#

not really

#

i'd say only 20% of our devs know anything about low level code at work

#

if you're into engine development then yes 100%

#

but if you're just a gameplay dev not really

muted field
#

well for unity sure but if you use c++ it would be nice to learn

rotund token
#

obviously if you're solo and have to do everything then yeah it'll probably creep in at some point

#

as you don't have anyone else to come in to optimize it

muted field
#

i am indeed solo

#

-_-

#
var list = lists[0];
list.Add(1);
lists[0] = list;

why can't we do:

lists[0].Add(1);?

rotund token
#

lists[0] doesn't return by ref

#

it's a local copy

#

you can add a ref return method

#
            where T : struct
        {
            return ref UnsafeUtility.ArrayElementAsRef<T>(array.GetUnsafePtr(), index);
        }```
muted field
#

ok so i need to think of it like a struct

rotund token
#

then you could do
lists.ElementAt(0).Add(1)

muted field
#

i might add some extension methods

#

to make my life easier

#

would be nice if unity did that so noobs can use them without having to think about all this too ๐Ÿ˜›

rotund token
#

i think unity's preference is users don't need to touch unsafe code

#

btw though they do have some of these

#

like dynamicbuffer has elementat method built in

#

just nativearray is missing it

muted field
#

true but even my case is a simple one that many people might need to do

#

with the other suggestion i could just opt for 1 array with [size][0]..[n][size][0]..[n] i guess

viral sonnet
#

InvalidOperationException: The Unity.Entities.EntityCommandBuffer has been declared as [ReadOnly] in the job, but you are writing to it. How odd is that? I never had any issues with it and the command buffer isn't read only. Yet Unity is complaining all of a sudden. hm

rotund token
#

are you passing it in a weird way

#

where its hidden from the scheduler so the safety system can't inject into it

#

i.e. passing it in via a pointer or something

viral sonnet
#

indeed I was ๐Ÿ˜„ was located in a struct that I accidentally marked ReadOnly

#

I've made such drastic changes today. I hope not everything comes crashing down lol

#

if it works out I've streamlined the shit out of the spell system ๐Ÿ˜„

#

aw man, I've changed duration from ushort to float and now all my authoring data is gone. Yet I was pretty sure as long as the name stays the same the data in the monoBehaviour persists

rotund token
#

you cant interpret ushort to float

#

if you had changed ushort to int

#

it would have kept

viral sonnet
#

huh? why is the cast not possible? float has enough range?

rotund token
#

unity doesn't convert them

#

the type isn't even stored on disk

viral sonnet
#

lazy unity ... ๐Ÿ˜„ yeah, the serialized file is 1:1 with ushort or float. glad I had a backup

#

must be some oversight. there's no technical reason I can think of

rotund token
#

if no . not float

#

๐Ÿ˜„

#

(but nah it doesn't work like that )

viral sonnet
#

some legacy UnityJS code ๐Ÿคฃ

rotund token
#

that said, i just converted an int to a float field

#

and it works fine

#

data still there

viral sonnet
#

yep, I did that pretty often over the years. either it's special for ushort or something else tripped up

rotund token
#

was it a list/array of ushorts?

viral sonnet
#

nope

molten flame
#

Does anyone know if there is an extension or something to access the hit child collider of a compound collider in a collision query?
I'm just working off the advanced collider parade demo which has everything I need but I can't help but feel that this is obvious functionality that has some extension hiding somewhere.

minor sapphire
#
if (collisionWorld.CastRay(raycastInput, out RaycastHit hit) &&
    !(projectile.Owner == hit.Entity && elspsedTime - birth.Time < 0.1f) &&
    !projectile.Destroyed)
{
    projectile.Destroyed = true;
    collisionWorld.Bodies[hit.RigidBodyIndex].Collider.Value.GetLeaf(hit.ColliderKey, out ChildCollider childCol);
    Collider* childColPtr = childCol.Collider;
    Collider projCol = *col.ColliderPtr;
#

If there is an obvious extension lying around let me know but otherwise... make an extension? ๐Ÿ˜„

#

I'm not aware of an easier way at the moment

molten flame
minor sapphire
#

are you by any chance generating voxels?

rotund token
#

Do you also have crazy cool lights?!

molten flame
#

No voxels or crazy cool lights for me.
I'm just using Rayfire to generate some high detail destructible walls.. its the one over the top ECS thing I want to do lol.

minor sapphire
#

I've been spending a stupid amount of time trying to optimise the CompoundCollider.Create call

#

made my own version of it, removing as many allocations and memcpy as I can, doing the BoundingVolumeHierechy generation upfront so I can pre allocate the blob memory and write directly to that lol

muted field
#

im getting this error:
Allocator Unity.Collections.AllocatorManager+AllocatorHandle must not be None or Invalid

not sure why though

#

theres no way to set a allocator to unsafe list from what i can tell

#

oh wait

#

i found it

rotund token
#

You still need to allocate and deallocate all unsafe containers

#

The difference is they are unsafe so they don't have safety to tell you

rotund token
muted field
#

if they persist for lifetime of the game do you still need to dispose when you exit the game or will that dispose auto ?

rotund token
#

Are you using ray fire just to create the fractures

#

Or integrating the whole thing

muted field
#

okay

#

i wonder if any one has released a nice wrapper around unsafe collections that handles some of the pains of dealing with them

molten flame
rotund token
#

They wrap an unsafe collection

muted field
#

yeh but cant have them in a struct that goes in a native collection

rotund token
#

I.e nativelist has a pointer to unsafelist

muted field
#

if thats all they are im surprised they wont allow collections that have structs containing collections

#

unless its on their roadmap to allow it some how

rotund token
#

Btw even when they finish removing dispose handle they won't allow nested native containers

viral sonnet
#

what's going on here? I have to complete the combined handles. otherwise unity complains about it, yet newHandle is a dependency for the job? anything obvious I'm missing here?

rotund token
#

They will have static analysis to prevent it

muted field
#

i dont know what you mean by that

#

i know you cant have NativeList<NativeList<>> but NativeList<MyStruct> which has a NativeList i feel like that should be possible if i can do it with an unsafe list and Native Lists are just wrappers

rotund token
#

They are removing this

#

In theory this means they can be nested

#

However they will add a static analysis to prevent it

#

I.e make it a compile error

muted field
#

why would they prevent it - seems like a nice idea to allow it surely?

rotund token
#

You could have 1000 lists inside each other

muted field
#

is it not costly to use an unsafe list like im doing though ?

viral sonnet
# rotund token What's the actual error

InvalidOperationException: The previously scheduled job UpdateCombatEffectsJob writes to the Unity.Collections.NativeList`1[NZSpellCasting.CreateBasicSpellDataComplex] UpdateCombatEffectsJob.JobData.casterCalulateSpellsList. You must call JobHandle.Complete() on the job UpdateCombatEffectsJob, before you can read from the Unity.Collections.NativeList`1[NZSpellCasting.CreateBasicSpellDataComplex] safely.

rotund token
#

There's no safety in unsafe

muted field
#

oh so the safety is what made it slower

rotund token
#

Btw I do actually have a list that you want

#

Think I call it unsafelistptr

viral sonnet
#

the system in question is handle3

rotund token
#

Acts like a native list without safety

#

On a tram will send you it when i get home

muted field
#

oh nice. ping me when you have it i will take a read of it ๐Ÿ™‚

#

thanks!

rotund token
#

Is it a native list

viral sonnet
#

yes

rotund token
#

And you're reading length

#

On main thread

#

When job could be writing to it?

viral sonnet
#

ah, good catch!

rotund token
#

If this is the issue you probably just need deferred job

#

Hard from me to be certain standing in a crowded tram with limited source code =D

#

Back in a bit

minor sapphire
#

excuses ๐Ÿ˜„

viral sonnet
#

seems like there is no defer job for IJobParallelForBatch :/

#

eh, completing at this stage is okay. was just wondering why that happens. sometimes the job dependency system still trips me up completely ๐Ÿ˜„

rotund token
#

Think it has batch option built in

#

It hasn't been update for new standards

#

Still used schedule for parallel

viral sonnet
#

just index ๐Ÿ˜ฆ

rotund token
#

Just have to calculate it yourself ๐Ÿ’ฉ

#

Bit of a pain

minor sapphire
#

Everything will be ok T_T

rotund token
#

Nope, better start refactor 71 enzi

muted field
rotund token
#

๐Ÿคทโ€โ™‚๏ธ

#

I don't find it a pain

#

Just need years of experience first!

minor sapphire
#

it is a bit of a pain though ๐Ÿ˜› just one that's worth it haha

rotund token
#

Then can do the basics

viral sonnet
#

I rather deal with pain than the Mono brick wall ๐Ÿ˜…

#

thanks for your help tertle! have a good night all o/

muted field
#

i would like my game complete before then lol

minor sapphire
#

It's the same humour I use every day

rotund token
#

Why release when there are still optimisations to be had!

muted field
#

lol so true

#

i think this is where im getting an error:

        public void Add(in Vector2 vertex)
        {
            float2 v = new float2(vertex.x, vertex.y);
            vertices.Add(v);
        }

ObjectDisposedException: The UNKNOWN_OBJECT_TYPE has been deallocated, it is not allowed to access it Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndBumpSecondaryVersion (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <823fb226a3f9439cb41fdcb61f9c86a1>:0)

#

but am not sure how to fix it

#

very hard to decipher the error's origin

minor sapphire
#

vertices?

muted field
#

vertices is an unsafe list

minor sapphire
#

check IsCreated

muted field
#

hmm strange maybe thats not the function causing it then

#

ok it might be when im adding to my native list:private NativeList<Polygon> _areas = new NativeList<Polygon>();

#

but that is also created

#

oh actually its not created ๐Ÿค”

#

so i can't declare a new native list as a class level field ?

#

can they only be created within functions

#

hm it works if i create the native list in a function but not if its declared as a class field

rustic rain
#

so...
I assume there is no graphic solutions in DOTS yet, so in order to draw some lines and etc, I need to use GameObjects?

rotund token
#

i have my own draw library but cant share it atm unfortunately

#

highly recommend something like this (grab it on sale)

pliant pike
#

I've used that its pretty good, although it does bog down your framerate if you try and render over 100,000 cubes or so

rustic rain
#

yeah, sadly I'm not really in position to purchase anything

#

Is there any free drawing library?

pliant pike
#

I mean its not that hard to use gameobject stuff instead

rustic rain
#

Well, that would require quite some sacrifices

pliant pike
#

yeah I guess it depends on what you want to use it for, if its just for debug purposes then it shouldn't matter surely

rich tusk
#

Is there any way I can find the problem why my capsule doesn't render after I set up my new project? I'm using URP with Entities cause I found it will render nothing at all if I don't use URP or HDRP (According to the Unity forum).

#

Not sure if there is something wrong with my capsule or something, I recreated one and it's still not rendered. the chunk I checked is normal to me but I'm new to ECS so don't know is there something missing.

pliant pike
#

are you sure its not fallen through the floor or flying off somewhere

rich tusk
#

It stays in the position in the scene view when play mode is on.

#

And when I tried another cube I removed the collider, didn't add the RigidBody, so it will not fall I guess.

rich tusk
#

Problem solved. I did what I miss in the guide, then created a material to solve the shader error, and the capsule rendered as I expected. Thx for the help!

rustic rain
#

How to do it correctly?
Basically, I need to access CompanionLink component of entity after it was added only once in order to add some other component.

#

Do I just create simple system where I target query which doesn't have yet the component I want to add?

solemn hollow
#

I dont know your exact usecase but you should probably use managed IComponentData on the entity instead of modifying the companion if all you need is to use managed Data for the entity

#

If you really need to access the Companion you can as you suggested query it. but i dont think you can query self added components directly on the companion. keep track of which companions are already processed by adding a tag to their entity which you can then exclude in the query.

rustic rain
#

I simple just add my other game object as child

#

and do whatever I want with it through my own component with reference to GO component I need

#

LineRenderer in this case

#

it's all irrelevant though

#

All I need is to somehow add component to entity only once, and just asking whether there is intended way for it

#

since I need to add it only after CompanionLink component is added

solemn hollow
#

i see. Just have a system that queries for CompanionLink and exclude the component with the reference to your own gameobject. Once your system did the processing and added your own "Companion" component it will never run again. You could use IsystemStateComponents for that to make cleanup easier

haughty rampart
#

@robust scaffold how's the source generator coming along? i'm curious

robust scaffold
#

(basically I accidentally overwrote the data files, and now I have no clue how to get it back. So ive gotta figure out what I did a loooong time ago and get my data files remade)

haughty rampart
#

Data files?

haughty rampart
pliant pike
#

damn, your reminding me I'm need to sort out some kind of source/version control I've had something similar happen leahS

robust scaffold
haughty rampart
robust scaffold
#

the PNGs are the main problem. Big 16k map textures

haughty rampart
#

How'd you break that with a source generator though?

robust scaffold
#

I have the original file, I did some sort of remapping in order to change the coordinate system.

robust scaffold
haughty rampart
#

Ahhh. Ok

robust scaffold
#

Yea, this was my own stupidity without backing it up.

haughty rampart
#

Version control system......

robust scaffold
haughty rampart
#

XD

rotund token
#

Just bind ctrl+s to commit

#

Side note - riders local history is great

muted field
#

I'm getting this error but don't know how to fix it:

_result is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.

I have it marked as write only because thats intentional:

        private NativeList<int2> _result;```

in the execute function i have:

if (result[0])
{
    var writer = _result.AsParallelWriter();
    writer.AddNoResize(new int2(index, i));
}

i was told this is how you are meant to write to a native list in parallel jobs yet it wont work
molten flame
#

Not really DOTS related but for some reason my active scenes aren't saved in the editor when I save and close. It always gives me a default scene when I load my project back up.
This isn't normal right?

#

It's not a big deal, my scenes are still saved, they just aren't active in the hierarchy and I have to reload them. Just seems wrong..

muted field
#

you can declare which one is default but yeh its not dots related at all

molten flame
muted field
rotund token
muted field
#

yeh i was just about to reply. wish the error would say that because the error is not helpful lol

pliant pike
#

isn't it also that all imported nativearrays will come up with that error ๐Ÿค”

muted field
#

define imported?

#

you mean created within a job ?

pliant pike
#

yeah if its local to the onupdate

rotund token
muted field
#

whats wrong with that line?

#

i read on the forum that you had to use that to write to a list in parallel jobs

pliant pike
#

a single array into a parrallel job is liable to have problems

muted field
#

thats why i was confused i had to declare it read only

#

because i wanted to write to it

rotund token
#

note that you can't increase capacity in parallel

#

you have to pre-allocate the capacity

muted field
#

is there no resize feature ?

#

for the writer*

rotund token
#

not in parallel

muted field
#

i guess that makes sense

rotund token
#

resizing requires reallocating to a new pointer

muted field
#

yeh i can imagine a race condition in that situation

rotund token
#

there are containers that do support resizing

#

such as NativeStream

muted field
#

ill have to keep that first job on the main thread and only do vertex overlap test on a job then

rotund token
#

as each thread can get its own stream

pliant pike
#

I see so that's what nativestream is for

#

I havent found a need for that yet I guess

muted field
#

how did you figure all this out - its tricky enough as it is with the current documentation details

pliant pike
#

personally I started this when there was literally almost no docs

#

I don't even know how I got anywhere with it

muted field
#

that would've frustrated me no end lol

rotund token
#

pretty much haven't ready any documentation

pliant pike
#

mostly I learned from the few tutorials that existed and help from the forums and this discord

rotund token
#

i have read probably the entire source code though

muted field
#

i would never have thought native stream existed to look for such a thing

pliant pike
#

yeah that's a bit beyond me leahS

muted field
pliant pike
#

I do sometimes look through the scripting api as well

rotund token
#

hell

#

no

#

they could not pay me enough to write documentation

pliant pike
#

some of the stuff doesn't even have vague descriptions of what they do though

#

or even if they do, theres no how to use them so its a lot of trial and error

muted field
#

i would never had known about parallel writer if it wasnt for searching the forums for a particular error that some one else had already had

pliant pike
#

yeah there's probably(definitely) a lot I still don't know about dots

#

but there's no need to learn everything at once

muted field
#

but the more i think about it, my approach wouldn't work due to race conditions anyway

pliant pike
#

if you keep to the safety systems then there shouldn't be much of a problem

muted field
#

how come a nativestream can be resized. but a native list cannot even though lists are known to be resizeable.

#

in parallel context anyway

pliant pike
#

because each thread gets their own unique nativestream

muted field
#

oh so you get a collection of streams at the end

#

rather than all bundled into one collection like a list would be

pliant pike
#

yeah I'm not sure how it works to be honest, is it all collected into one single array at the end perhaps

rotund token
#

nope

#

you can read it back in parallel

#

or you can merge it into a single stream/list if you want

#

ideally you don't need to do that though

pliant pike
#

ok that makes sense

rotund token
#

btw NativeQueue.ParallelWriter can also resize in parallel

muted field
#

oh so they support queue but not list ๐Ÿค”

#

that seems even more strange to me

viral sonnet
rotund token
#

it's /fine/

#

much faster than default nativelist for example

#

honestly it's a great first container for most people

#

solves a lot of thread issues etc

#

while performing well

#

i don't use it much anymore but it still has its uses for convenience

viral sonnet
#

I can't remember what the issue was. Seems there's no parallel reader

rotund token
#

there's not

#

that said a parallel queue reader wouldn't make any sense?

viral sonnet
#

Guess that was it, from source reading seems limited

rotund token
#

it's a queue it's meant to be ordered

viral sonnet
#

yeah, good point ๐Ÿ™‚

muted field
#

some weird inconsistencies with their collections the hash set Count is a method yet in list its a property

rotund token
#

so that hybrid thing we hate enzi

#

i got my workflow working amazing

viral sonnet
#

tell me more ๐Ÿ™‚

rotund token
#

i have skin meshed renders in the world but dont show up in hierarchy

#

when you select them in scene view they select the enitty

#

(i.e. i added skinned mesh renderers into the entity picking stuff)

#

for normal workflow you can legit not tell they are gameobjects

#

it just feels pure

#

the whole setup is automatic

#

simply add a

#

hybrid component authoring script to an entity

north bay
rotund token
#

with the gameobject/any components

muted field
rotund token
#

and then my setup automatically adds component references i need

viral sonnet
#

sounds great. anything to share? your comp certainly has the same logic as mine

rotund token
#

yeah i'll probably share this whole thing soon~

#

it's very simple actual

#

should have turned off gizmos before i recorded this ๐Ÿ˜„

viral sonnet
rotund token
#

oh i dont have anything like this

viral sonnet
#

I've written this some time ago. Could be simplified I guess. I was never too sure how to handle subscenes/normal scenes and conversion vs. no conversion

rotund token
#

i instantiate at runtime

viral sonnet
#

same here.

#

this is just the comp that does the setup + drawing so I can see a mesh

rotund token
#
            {
                var entity = this.GetPrimaryEntity(hybrid);
                this.DstEntityManager.AddComponentData(entity, new HybridComponent { Prefab = hybrid.Prefab });

                switch (hybrid.CopyMode)
                {
                    case HybridComponentAuthoring.CopyModes.None:
                        break;
                    case HybridComponentAuthoring.CopyModes.CopyTransformToGameObject:
                        this.DstEntityManager.AddComponent<CopyTransformToGameObject>(entity);
                        break;
                    case HybridComponentAuthoring.CopyModes.CopyTransformFromGameObject:
                        this.DstEntityManager.AddComponent<CopyTransformFromGameObject>(entity);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            });```
#

my entire authoring

#

all my authoring scripts exist in editor asmdef

#

to strictly disallow runtime authoring

viral sonnet
#

does this run in Convert?

rotund token
#

you mean convert to entity?

#

no that is runtime authoring

#

strictly disallowed ๐Ÿ˜…

viral sonnet
#

the code you posted. not a system, right?

rotund token
#

oh

#

sorry

#
    {
        protected override void OnUpdate()
        {
            this.Entities.ForEach((HybridComponentAuthoring hybrid) =>
            {
                var entity = this.GetPrimaryEntity(hybrid);
                this.DstEntityManager.AddComponentData(entity, new HybridComponent { Prefab = hybrid.Prefab });

                switch (hybrid.CopyMode)
                {
                    case HybridComponentAuthoring.CopyModes.None:
                        break;
                    case HybridComponentAuthoring.CopyModes.CopyTransformToGameObject:
                        this.DstEntityManager.AddComponent<CopyTransformToGameObject>(entity);
                        break;
                    case HybridComponentAuthoring.CopyModes.CopyTransformFromGameObject:
                        this.DstEntityManager.AddComponent<CopyTransformFromGameObject>(entity);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            });
        }
    }```
#

it's just a GameObjectConversionSystem

#

originally i had a bunch of other logic

#

which is why it's a system

#

but i should probably move it to a IConvertGameObjectToEntity now that it's not required

viral sonnet
#

ah, I see. I remember having some trouble with getting the correct entity index. either there was some bug or limitation but I had a weird way of working around it

rotund token
#

but yeah i dont create a separate presentation entity

#

the components are attached directly to the actual entity

#

but this is only done on the client