#archived-dots

1 messages ยท Page 13 of 1

viral sonnet
#

hm, i find dots a lot less prone for restarting. my <0.17 entities projet is something different though

#

just entities.foreach and componentsystems. hardly any burst ๐Ÿคฎ

#

and lots of add/remove haha

#

Overall a good case of what you should not do

rustic rain
#

hmm

#

quite so annoying

#

can't convert primitive values to FixedString

viral sonnet
#

is burst 1.8.0-pre.2 usable?

rustic rain
#

works fine for me

viral sonnet
#

ok great. thanks ๐Ÿ™‚

#

it sucks so hard that partial methods can't have return values -.-

#

i don't quite know how to get around that. basically i use methods that could or could not be source generated. but yeah, i need some form of placeholder. one of these methods is a get value. can't do it, it seems :/

#

hmmm, SO says ref works. that would be okay

rustic rain
#

can't you use out?

viral sonnet
#

no

#
    It doesn't have any accessibility modifiers (including the default private).
    It returns void.
    It doesn't have any out parameters.
    It doesn't have any of the following modifiers virtual, override, sealed, new, or extern.
rustic rain
#

could potentially change field

#

and wrap it all in some getter

#

get{ PartialMethod(); return _field;}

viral sonnet
#

seems dumb but partial is just a merge basically so you could have 2 methods that return. i don't see the issue though. compiler should complain. done

#

i don't care if enterprise coders can't get their shit together ๐Ÿ˜„

rustic rain
#

hmm

#

can I cast ISystem to other interface through it's pointer?

viral sonnet
#

sure, but why? just cast to your struct or do you need some generic method?

rustic rain
#

yeah, it's generic

#

I need to make a callback for ISystem through interface

#
            foreach (var system in World.Systems)
            {
                if (system is IUILoadedCallback callback)
                {
                    callback.OnUILoaded();
                }
            }

For managed it's simple

viral sonnet
#

yeah casting should work. not sure about the ptr though. never done it but in theory i see no problem

rustic rain
#

how to cast it?

viral sonnet
#

get the system struct through World.Unmanaged

rustic rain
#

this is it

#

not really struct

viral sonnet
#

huh? i mean get the struct and cast to your interface

rustic rain
#

that's what I do

#

but

#

I can't get actual struct

#

in generics

viral sonnet
#

not on my computer. look at the return value

rustic rain
#

SystemHandleUntyped

viral sonnet
#

there's definitely the system struct in there

#

I'll take a look when I'm re

rustic rain
#
                var sys = World.Unmanaged.GetExistingUnmanagedSystem(type);

                unsafe
                {
                    var sysPtr = World.Unmanaged.ResolveSystemState(sys);
                }

ok I got direct pointer to system state

#

now

#

cannot do direct cast either

#

hmm

#

maybe I can make a call through reflection?

viral sonnet
#
ITestInterface test = (ITestInterface)system.Struct;```
rustic rain
#

well that works if you know exact type to get

#

in my case

#

I don't

viral sonnet
#

why don't you? ๐Ÿ˜„ your code isn't a black box to you. reflection won't work i think. the isystem is all in unmanaged space.

#

for generics i'd stay with systembase

#

or you register the type somewhere to find it out through the handle

rustic rain
#

I want to have a callback in ISystem

#

similiar to OnStartRunning

#

or OnDestroy

viral sonnet
#
        {
            if (_unmanagedSlotByTypeHash.TryGetFirstValue(BurstRuntime.GetHashCode64<T>(), out ushort handle, out _))
            {
                var block = _stateMemory.GetBlock(handle, out var subIndex);
                var sysHandle = new SystemHandle<T>(handle, block->Version[subIndex], (uint) SequenceNumber);
                void* ptr = (void*)(IntPtr)block->SystemPointer[subIndex];
                return new SystemRef<T>(ptr, sysHandle);
            }
            FailBecauseSystemDoesNotExist();
            return default;
        }```
rustic rain
#

yeah, I can't use T

#

I only have Type

#

as an object

viral sonnet
#

that's how you get a block and the ptr

#

the untyped handle has all the info

#

i think you were on a good track with ResolveSystemState. you could use an empty struct that implements your interface

#

then call it through the struct as the interface isn't working for T

#

oh right, they are partials. there might be some trick here

rustic rain
#

eh

#

I scrapped the idea

#

I figured other way to have async

#

way to handle this

#
    public abstract class UIAddon
    {
        protected World World { get; private set; }

        internal void Create(World world)
        {
            World = world;
            OnCreate();
        }

        protected virtual void OnCreate() { }
    }

Kek

#

They are created on demand

#

through reflections

#

and then cached in some system

#

so later I once UI is loaded I can supply them with OnCreate virtual

#

sadly it's only managed

#

but so far, it's only managed types that need it

rotund token
rustic rain
#

yeah, and I wanted to have similiar callback

#

but my own

#

for when UI is loaded

elfin spire
#

I'm getting loads of these when churning meshes with the Mesh API System.InvalidOperationException: Mesh data does not have {0} vertex component, any idea what that means?

#

that's with BURST on, with BURST off i get InvalidOperationException: Mesh data does not have Position vertex component

rustic rain
#

I would guess that your Mesh data does not have Position vertex component ๐Ÿ˜…

elfin spire
#

๐Ÿ’ช lol

#

might be a mesh that is empty then

#

voxel engine makes loads of crap output

#

added a test and it's fine now, thanks haha

drowsy pagoda
#

In a situation where I need to use the managed debugger on standalone player from DOTS build using Rider. I can't seem to get it to work. Can someone help me troubleshoot this?

rustic rain
#

Can't debug bursted code with managed debugger

robust scaffold
rustic rain
#

Even 2022 simply disables burst

#

It's just that it does it in a convenient way without a need to rebuild

robust scaffold
#

But you can still debug

rustic rain
#

You debug in 2021 too

#

But you'll have to disable burst manually for that job

viral sonnet
#

has anyone tried source generators? I can't get any output. just testing my generator with a test project, not unity. any special sauce needed?

#

oh wow, missed the [Generator] tag ...

rotund token
#

that sounds important

viral sonnet
#

kinda ๐Ÿ˜„ here i thought ISourceGenerator is enough

#

i built myself a nice rabbit hole. first i generate a cs file with data and then i need the analyzer and source generator to use some templates to write the actual code with the relevant data types, stats and methods ๐Ÿ˜„

#

sadly c# is not very versatile when it comes to numeric data types being generic. total pain and honestly, kind of unexpected. even c++ is more versatile

balmy thistle
#

fascinating, what in particular would be the language support you'd ideally add

viral sonnet
#

using simple data types as T for generic methods would make it a lot easier. couldn't get it to work and using the struct version of the data types is a pain and hurts performance afaik

rotund token
#
    public struct JobInt : IJobFor
    {
        [ReadOnly]
        public NativeArray<int> Input;

        public NativeArray<int> Output;

        public void Execute(int index)
        {
            this.Output[index] = this.Input[index] + 4;
        }
    }

    [BurstCompile]
    public struct JobIntOperation : IJobFor
    {
        [ReadOnly]
        public NativeArray<IntOperation> Input;

        public NativeArray<IntOperation> Output;

        public void Execute(int index)
        {
            this.Output[index] = this.Input[index].Add(4);
        }
    }```
these 2 jobs generate the exact same burst for me
#
        where T : unmanaged
    {
        T Add(T b);
    }

    public struct IntOperation : IOperation<int>
    {
        private int value;

    public struct IntOperation : IOperation<IntOperation>
    {
        private int value;

        public static implicit operator int(IntOperation i)
        {
            return i.value;
        }

        public static implicit operator IntOperation(int i)
        {
            return new IntOperation { value = i };
        }

        public IntOperation Add(IntOperation b)
        {
            return this.value + b.value;
        }
    }```
#

i'll test it as a generic in a sec

viral sonnet
#

cool thanks, but that's what i mean you have to write all these implementations

robust scaffold
#

Generic types is fine in burst. Burst just compiles all possible usages of the type

viral sonnet
#

maybe that particular path is even worth exploring. sure implementing all this is tedious but once done it works. 2nd time i want to set foot in source generators and there are other (better) solutions

#

but this rabbit hole goes much deeper now and i want to strip/add whole code ๐Ÿ˜„

rotund token
#

just to confirm for you

            where T : unmanaged, IOperation<T>
        {
            for (var i = 0; i < input.Length; i++)
            {
                output[i] = input[i].Add(v);
            }
        }```
generates the exact same code as just using int
the struct is just completely stripped (as i expected)
viral sonnet
#

ok sick

#

that's great ๐Ÿ˜„

#

thanks

rotund token
#

single field structs are basically just treated as the field

viral sonnet
#

ok i'm investing a bit more into this. maybe you have successfully kept me from going with source generators ๐Ÿ˜„

#

i prefer not using SG ๐Ÿ˜„

devout prairie
#

is it possible to profile a build?

viral sonnet
#

which tool? it works for me

#

have used superluminal and vtune

#

you can even profile the editor

devout prairie
#

i've literally never tried just curious.. well i was thinking maybe a debug build and standalone unity profiler or something

viral sonnet
#

no idea about debugging builds, never did so. unity profiler attaches just fine

devout prairie
#

just feel all the editor stuff gets in the way when for example sorting for whats taking longest etc in hierarchy view

#

so i was thinking, can i avoid all that by profiling a build

rotund token
#

you can attach unity debugger to development builds

devout prairie
#

as in the profiler though?

#

stuff like this for example

viral sonnet
#

yes i just use this setting

devout prairie
#

the EditorOnly taking up a chunk of time and skewing the sort order in the hierarchy view

devout prairie
#

well i guess

#

never noticed this before

viral sonnet
#

your machine will also show up here

#

always worked very reliable for me

devout prairie
#

nice thanks

#

yeah profiler launches nicely alongside Build&Run

viral sonnet
#

damn, my project is kind of broken. why is unity not compiling my asmdef that has updates to the source generator?

#

can i force someway to just compile the asmdef? it will compile. reimport doesn't work

#

this is dumb. compilation stops before getting to the asmdef. making another project then ...

rotund token
#

im not sure about 2021

#

but in 2020 you had to add 2 labels to your source gen asmdef for it to trigger

#

i believe this isn't required in 2021 though

viral sonnet
#

not using any real source gen dlls. just a simple script that evaluates a scriptable object

#

well, i'm generating it now in a new project. i don't get it why it just stops compiling.

#

maybe i can get away with just htis. that would be nice ๐Ÿ˜„

jovial mantle
#

Hi guys, anyone can point out what low hanging fruit can I benefit from using C# Jobs in a done traditionally with Monobehavior/GO ? thanks

devout prairie
#

Wondering if anybody can explain this to me because i don't fully understand it..

#

If i spawn a lot of physics bodies into my scene i'll see multiple build and step physics worlds inside the frame like this:

#

I'll get more build/steps per frame the more bodies etc i have in the scene:

robust scaffold
robust scaffold
#

If fixed step time becomes larger than frame time, fixed step enters a death spiral where it keeps iterating per frame

devout prairie
#

Yeah this is the part i'm struggling with

robust scaffold
#

The issue with implementing your own and fixing the death spiral is that it loses the "stateless" feature of unity physics

#

If you dont care about it being stateless, then yea. Go ahead.

devout prairie
#

I mentioned this a while back but i did notice it's possible to just null out the RateManager and it forces one build/step per frame, but i'd rather 'understand' what's going on

devout prairie
robust scaffold
#

What is the spiral of death? Itโ€™s what happens when your physics simulation canโ€™t keep up with the steps itโ€™s asked to take. For example, if your simulation is told: โ€œOK, please simulate X seconds worth of physicsโ€ and if it takes Y seconds of real time to do so where Y > X, then it doesnโ€™t take Einstein to realize that over time your simulation falls behind. Itโ€™s called the spiral of death because being behind causes your update to simulate more steps to catch up, which causes you to fall further behind, which causes you to simulate more stepsโ€ฆ

#

The fix is now "caching" the uncompleted fixed step event that took longer than FPS and not locking graphics update. Finishing the fixed step next frame and so on

#

Well, there is another option. Which is cutting fixed step time even more so it lands under framerate. And then interpolating the results.

#

That retains stateless but it may result in wonky physics with high time steps. And mandatory continuous collision detection which may be even more expensive

devout prairie
#

god damn that's a head-f*&^

#

but i think i understand what you're saying re caching the step and completing later ie it becomes stateful in that case

robust scaffold
#

Yep. Physics is a wild rabbit hole.

devout prairie
#

what i was thinking was:

#

say in some old school game, if it started to lag, the physics itself would also lag ie it would slow down in accordance with your fps slowdown

#

so you have say an explosion that takes 20 seconds to complete or whatever

#

can't the step simply be locked to display fps in that way?

robust scaffold
#

Old school may have framerate locked physics.

devout prairie
#

say if it's not networked, and you don't care about determinism or any of that

#

but you also don't want death spiral

viral sonnet
#

lock to just 1 timestep?

devout prairie
#

does nulling out the RateManager achieve that or is there more to it

#

Basically, this line of code gives me my fps back:
World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<FixedStepSimulationSystemGroup>().RateManager = null;

#

Because it then only does a single build/step per frame

robust scaffold
#

Alternatively, you can unlock frame update but that means the user can run around, do whatever, then 20 seconds later a very delayed explosion happens and what the user did to physics objects will not match what the computation expects

#

and the physics go wild, moving in unexpected ways since the user changed the state of the physics while it was computing

#

or the user cant move, which is just option 1.

devout prairie
#

Well what i mean by 20 seconds is, the simulation plays back in 'slow motion' because it plays back at say 2 fps or something, in an extreme lag situation

robust scaffold
#

You really cant play a physics in "slow motion" It doesnt work that way

#

reducing the time step doesnt reduce the computation cost

#

In fact, it increases it exponentially

#

The cost of physics is determining overlaps from axis aligned bounding boxes and then determining if, yes, this object does collide with this other object.

#

That is required per time step. Regardless of the length of it.

devout prairie
#

So i think my idea is basically what you were suggesting, ie frame locking it

robust scaffold
#

Then yes, setting rate manager to null will frame lock it

#

But the issue is that now, the physics might not simulate correctly with variable timesteps

devout prairie
#

So if it takes x ms to compute the step, it does that and does not move on to render the frame until it's done with that

rotund token
#

@devout prairie i might have missed something but is that from editor or build?

robust scaffold
#

Yep

rotund token
#

do you have physics integrity checks on?

devout prairie
#

uhh

rotund token
#

Dots -> Physics -> Integrity checks

devout prairie
#

yeah

rotund token
#

turn that off

devout prairie
#

i do

#

does that become disabled in build?

rotund token
#

yes

#

but from your profile

#

to me you have like every safety feature on

#

which really kills physics in editor

devout prairie
#

i do yeah, in editor

rotund token
#

turn off safety, jobs debugger and integrity checks and how does it compare

#

if you want to run these in editor it's often worth just dropping your fixed step to 20 or 30 in editor

#

to avoid killing your machine

robust scaffold
#

If you can keep physics update less than framerate, then you dont need to change the default physics simulation

#

But lower time steps results in higher changes for object tunneling and collision misses for fast objects. Might be worth it for generally better performance.

devout prairie
#

tbh it's pretty much the same with those off:

safe lintel
#

make sure you dont have more than one PhysicsStep in your scene like I did ๐Ÿคก

rotund token
#

seeing a lot of GC

devout prairie
#

so Off is definitely a bit better:

rotund token
#

all that red stuff should not exist

#

how many colliders?

devout prairie
#

that's the parallel contacts job and build jacobians

robust scaffold
#

How many objects?

devout prairie
#

a few ๐Ÿ˜›

rotund token
#

so 3-7?

#

because that's a useless response

#

i have absolutely no allocations when i have all safety systems off

#

so as far as i can tell

#

you have something on

devout prairie
#

Entities count on the StepPhysicsWorld system is 7204

rotund token
#

all dynamic i assume?

#

i can handle up to about 40k dynamics

#

before it breaks down

devout prairie
#

almost all using joints

rotund token
#

well that might be the problem then

safe lintel
#

thats alot of joints

devout prairie
#

it's 600 ragdolls yeah

#

i think 12/13 joints on each

viral sonnet
#

are they all on screen? because i see half simulation rate on far away objects a lot

devout prairie
viral sonnet
#

what's your sim speed? i see 14.5ms for 1 physics step alone. that's almost at the 60fps limit for just a step

viral sonnet
#

hm, not that the sim speed matters much here. is 1 step always this high or just when you instantiate?

#

the way i see it, to solve this problem is to get the step down at least to 7-8ms. 7ms or lower would be better, you want to have leeway for 1 extra step before spiraling.

devout prairie
#

i've early exited my other systems with 'return' just so that i can focus on what physics is doing on it's own

viral sonnet
#

some form of staggered instantiate could also work. not all at once but one by one

devout prairie
#

instantiate is ok tbh

#

so this is profiling the debug build::

rotund token
#

your physics is taking your entire frame budget (17ms of 16ms for 60fps)

#

so if you do anything else in your entire frame you will spiral down

devout prairie
#

to be clear i'm deliberately spawning a lot of these, to obviously stress test it

#

so my original question was why does it repeat these build/steps multiple times per frame

#

i think KornFlakes kindof answered it in a way that made some kind of sense

balmy thistle
#

physics often runs with a fixed small timestep

#

which is looped until you hit some convergence threshold

devout prairie
#

i guess the next question was, what's a good approach to combat that spiral or should i just limit how much i'm spawning basically

balmy thistle
#

because with discrete physics you're handling the collision response at the same time as your contact point generation, so you want to make sure you don't miss an intersection that might happen with a big timestep

#

also because it leads to more consistent convergences. You can imagine just doing one giant physics step would be much less stable than 10 little ones

devout prairie
#

so would simply locking the physics step to the frame be a bad idea?

#

ie the frame doesn't render until the step calculates

#

whether it takes the step 1ms or 50ms

balmy thistle
#

I wouldn't expect to see that in a real game

devout prairie
#

putting aside the concept of the simulation running in 'realtime' ie locked to the world clock

#

basically if it takes longer to sim the step, then it takes longer

#

is that a) possible and b) a bad idea ๐Ÿ˜›

#

kinda like how an oldschool game might have done it

#

say if you have too many explosions, everything slows down including the explosions/physics

viral sonnet
#

the obvious and unsatisfying answer to this problem is, never ever let it happen ๐Ÿ˜„

#

that's really the problem with fixed timestep physics. what older games did was have a variable rate of step time.

#

afaik they were bound to render time

rotund token
#

(this is not a new problem either btw, this is how the regular physics works in unityengine)

viral sonnet
#

yep, and it's pretty much how all modern physics engines work. i'm not aware of any other method

#

unless you step manually with your own timestep

#

the physics engine doesn't really care

devout prairie
#

i guess coming from an animation/cgi background i'm kindof used to seeing it like this:

#

you run an animation with dynamics simulation in the viewport, if it's not too heavy it'll playback at a nice 30-60fps

#

when it gets bogged down the simulation plays back slowly

viral sonnet
#

wdym slowly? how would it ever catch up? i guess they only run 1 step each frame. at least that's what would i do when realtime framerates are not the issue

devout prairie
#

that's what i mean yeah i guess it runs 1 step per frame

#

so if that step takes 30ms to simulate then you wait 30ms until the next frame update in the vp

viral sonnet
#

@rotund token i'm generating now a bunch of those. need to see how this solution holds. right now it looks pretty good

#

no need for any generics that way ๐Ÿ™‚

errant hawk
#

should components have any sort of logic? I get that the system or jobs are supposed to handle that, but couldn't I just stuff all the relevant methods in the component and call them when necessary?

#

also, I noticed that a lot of components dont even have constructors

balmy thistle
#

yeah no

viral sonnet
#

hehe, i've been a pretty big opponent of using var. then i've started to use it while learning entities a lot more because types got so verbose. now i love it because it enables me to return any dataType i want without changing any code

balmy thistle
#

It helps to have an IDE that shows you the type info selectively (like Rider).

viral sonnet
#

i've turned that feature off in rider ๐Ÿ˜… no idea why, i don't like it

balmy thistle
#

well I use emacs so don't consider this a personal endorsement

viral sonnet
#

using this struct solution, the code got cleaner than i imagined. good thing tertle brought this up. even though i'm using something completely different, it held me off enough to get knee-deep in source generators. and considering what i have now. it would have been a total waste. still code generating but no ISourceGenerator, just good old stringbuilder ๐Ÿ˜„

#

are you deving on linux or is emacs just a personal preference?

balmy thistle
#

personal preference, I've long since committed to emacs for everything

errant hawk
#

Has anyone done any performance benchmarks of (both using burst) IJobEntity vs a normal job? To be more specific, Im interested in raycasting performance using the Unity Physics package.

rotund token
#

IJobEntity just code gens into IJobEntityBatch

rustic rain
#

wait what

#

ISystems are not created during OnCreate phase?

#

var ccb = World.Unmanaged.GetExistingUnmanagedSystem<CollisionCommandBuffer>();

rotund token
#

what is CollisionCommandBuffer?

#

is that a system

rustic rain
#

yes

rotund token
#

an ISystem?

rustic rain
#

yes

rotund token
#

how is it a 'commandbuffer'

#

and are you getting this from a managed system?

rustic rain
#

it has a buffer

#

my own one

rustic rain
rotund token
#

yeah

#

i believe all managed systems are created

#

then all unmanaged systems are created

rustic rain
#

welp

#

bruh

#

how do you even work with ISystem

rotund token
#

what do you mean?

#

you're not really meant to 'work with it'

rustic rain
#

But I need bursted update

rotund token
#

and ISystem can do that

rustic rain
#

well yeah, and I need it to work with ManagedSystem

rotund token
#

why

rustic rain
#

as command buffer

rotund token
#

nothing you have said indicates you need to access an ISystem

rustic rain
rotund token
#

a) i have many times very strongly expressed my disagreement with ever accessing collections in other systems
b) use a systembase

#

you know you can't store a native container in a ISystem anyway right?

rustic rain
#

even unsafe?

rotund token
#

sure

#

an unsafelist won't work though externally

#

only the hashmaps really will work

#

but again b) use a systembase

rustic rain
#

how can I burst it then?

rotund token
#

by putting it in a job

#

or calling a function pointer

#

which is all ISystem is doing

#

are you that pressed that you need to save 0.05ms by converting SystemBase to an ISystem?

rustic rain
#

I'm learning my tools, cause I wanted to use that approach in future

#

I guess what I could do instead

#

is create entity with Buffer

#

and store all data here

#

kek

rustic rain
#

WAIT WHAT

#

since when Unity Physics debug view works in game view?

#

pooog

#

brrrrruuuuh

#

it's "GIzmos"

#

I never turned it on in play mode

hollow jolt
#

why my float3x2 variable won't change after completing a IJobParallelFor ?

#
bounds = new float3x2( math.min( v[i], bounds.c0 ), math.max( v[i], bounds.c1 ) );```
#

executing the same exact line on a normal loop outside of a job would work exactly as expected

rustic rain
#

you gotta share more code than that

hollow jolt
#
    [BurstCompile] struct ComputeBounds : IJob
    {
        [ReadOnly] public NativeArray<Vector3> verts;
        public float3x2 bounds;
        public void Execute() {
            for (int i = 0; i < verts.Length; i++) {
                var v = verts[i];
                bounds = new float3x2(
                    math.min(v, bounds.c0) , 
                    math.max(v, bounds.c1) );
            }
        }
    }

    static readonly float3 MAX3 = new float3(float.MaxValue, float.MaxValue, float.MaxValue);
    static readonly float3 MIN3 = new float3(float.MinValue, float.MinValue, float.MinValue);
#
var job = new ComputeBounds { bounds = new float3x2(MAX3, MIN3), verts = vertices };        
job.Schedule().Complete();
#

that's it ...

#

tried both IJobParallelFor and IJob

solemn hollow
hollow jolt
#

can u give me an example of a native container for a float3x2 ?

solemn hollow
#

there is none :/. AFAIK you have to use something like a NativeArray<float3x2> with a size of one

rustic rain
hollow jolt
#

after Complete()

rustic rain
#

should be it

hollow jolt
#

ยฏ_(ใƒ„)_/ยฏ

rustic rain
#

can't you just share whole code block from start to end?

hollow jolt
#

ill use array[1]

#
var job2 = new ComputeBounds { bounds = new float3x2(MAX3, MIN3), verts = vertices };
job2.Schedule().Complete();
this.bounds = job2.bounds;
#

that's all there is

#

i'm not even scheduling it on the previous job , made sure its a separate one

rustic rain
#

verts.Length
Are you certain it's not 0?

hollow jolt
#

when should i check if not 0 , before schedule or after ?

#

well its not

#

not before , nor after

#

just checked

rustic rain
#

if it's 0, that would mean your bounds are unchanged

#

cause no work happened

#

try

hollow jolt
#

ill try with NativeArray[1]

hollow jolt
rustic rain
#

nvm

hollow jolt
#

im speed

#

yep that worked

#

array[1] it is

solemn hollow
hollow jolt
#

yep

#

i isolated it from a bigger job

#

will try merge those two

solemn hollow
#

i see

hollow jolt
#

its been a while since i used burst , had been using nativeArrays just now

rustic rain
#

Burst is life

solemn hollow
#

that problem you had had nothing to do with burst though

hollow jolt
#

ye i love it , gotta say the whole setup and dispose is very messy code

#

it nearly triples the lines of code for the same task

rustic rain
#

well, for one you don't really need Schedule, if you instantly check for result - just run

hollow jolt
#

ye after i merge ill just do
Schedule().Complete()

rustic rain
#

Run() is faster equivalent of that

hollow jolt
#

i don't have it

rustic rain
#

But you do

#

it's extension method

hollow jolt
#

oh nvm , was trying to look it up in the Handle

#

thanks

solemn hollow
#

why complete at all? just schedule the second job after the first with a dependency on the first

hollow jolt
#

that's what im doing rn

hollow jolt
#

but i want to move the code inside the first one

rustic rain
#

if you have 2 jobs that need to be run in sync

#

Running them is fasteest

solemn hollow
#

yeah if you want it single threaded

hollow jolt
#

what was that [Decorator] which allows writing to the same array-index in parallel ?

rustic rain
#

[DisableNativeParalellRestrictions] or smth like that

hollow jolt
#

if i would do something like single var container

rustic rain
#

use intellisense to figure actual name xD

hollow jolt
#

yes i did ๐Ÿ™‚

#

was looking up Parrallel but no intelisense

#

btw

#

Run has no innerLoopBatchCount

rustic rain
#

You have IJob

#

in code you shared

hollow jolt
#

IJobParallelFor

#

in another job

rustic rain
#

in that case, yeah

#

you need to schedule

hollow jolt
#

what will it do if i just Run( arrayLength ) ?

rustic rain
#

no parallel

#

all on mainthread

hollow jolt
#

ah interesting

#

will keep that in mind

rustic rain
#

but it is faster than scheduling if threads not worth it

#

I sometimes implement double job system which checks for amount of data to process

#

if it's small amount, I just do Run with IJob

#

if it's big - parallel

hollow jolt
#

ye i figured

#

actually making it parallel reduced 1/2 ms

#

from 2 miliseconds to 1.5 miliseconds

#

but im doing a big innerLoopBatchCount

#

the test mesh im playing around with don't have too much verticies ( ~ around 4k verts )

#

so im guessing the parallel will help with larger meshes

#

finally got some bounds

#

now ill go read about Graphics.Draw API ๐Ÿ˜„

radiant berry
#

Does DOTS have support for pooling or like documentation on pooling with dots?
Like an example with projectiles for example?

rustic rain
#

all memory is preallocated on chunks

#

if you mean ECS

radiant berry
#

yeah, any idea where i can read on the differences of memory just a very basic explanation

#

Just so i know why pooling is not needed in DOTS

rustic rain
radiant berry
#

I am reading through it and does it determine the size of the chunks based on the components an entity has

rustic rain
#

chunks are fixed size

#

chunk capacity depends on archetype

#

basically, how much can you fit in fixed byte array

radiant berry
#

i see, i think i understand it a little better now but not yet that much

#

But i am waiting for it to go to 1.0 before i will do something with it so i have time

rustic rain
#

ECS is a whole new concept that requires a lot of time to invest, before you can finally understand it

#

syntax is not much of an issue

#

it's literally "thinking" that is most of the problem, kek

radiant berry
#

yeah, i think from how it works the biggest thing is the way stuff interacts and how you should make your systems

rustic rain
#

one thing that annoys me most: OOP best practices are worst for ECS xD

radiant berry
#

yeah, that's a big adjustment i think/hope they make some good examples for how you would do something in ECS that was first done with normal gameObjects when 1.0 is out

rustic rain
#

ECS is not unique to Unity

#

it was made long before Unity has even started making engine

#

best practices of ECS are already available, basically hehe
But it's all conceptual

cunning bloom
#

I'm trying to load a subscene using LoadSceneAsync. It doesn't load in a standalone build but it does work in the editor. Is there something I've missed?

Here's the relevant loading snippet. The async loading task is started but isSceneLoaded never returns true in a standalone build.

var world = World.DefaultGameObjectInjectionWorld;
var sceneSystem = world.GetExistingSystem<SceneSystem>();

// Hard coded for testing. This is a subscene guid copied from the editor.
Unity.Entities.Hash128 subSceneGUID = new(
    x: 3353769547,
    y: 1097787817,
    z: 3813202594,
    w: 44277289);

Entity sceneEntity = sceneSystem.LoadSceneAsync(subSceneGUID);

// This will load in the editor's play mode but will never succeed in a standalone build.
while (sceneSystem.IsSceneLoaded(sceneEntity) == false)
{
    Debug.Log("waiting for prefabs scene to finish loading");
    yield return new WaitForFixedUpdate();
}

For the standalone build I'm using the platforms package. The subSceneGUID above is a subscene of SimulationEntityPrefabs in the Scenes Info list.

rustic rain
#

is subscene part of scene?

cunning bloom
#

Yes, it's part of SimulationEntityPrefabs in the Scenes Info list (Element 1).

rustic rain
#

just make serialized references in some mono to subscenes you need

#

and then grab all guids from it

#

I think this way you can even save this mono as prefab, serialized too

#

haven't tested it though

cunning bloom
#

Thanks, although won't that ultimately lead to the same issue? I'm eventually going to pass a guid to SceneSystem.LoadSceneAsync, so it'll essentially function like the snippet above?

rustic rain
#

which might be the case

#

why guid is different

cunning bloom
#

I replaced the hardcoded GUID with:

Unity.Entities.Hash128 subSceneGUID = sceneSystem.GetSceneGUID("Assets/Scenes/SimulationEntityPrefabs/PrefabsSubScene.unity");

According to the documentation that will look up the GUID in StreamingAssets/catalog.bin so it should be correct (and it did match the guid I hard coded).
So unfortunately the issue seems to be caused by something else.

rustic rain
#

is your subscene inside your scene?

#

as in game object?

cunning bloom
#

The subscene is inside the "SimulationEntityPrefabs" scene. However, that scene isn't loaded at runtime. I only attempt to load the subscene through Unity.Scenes.SceneSystem. There's no references these scenes in gameobjects.

What's currently happening is:

  1. Game starts with boot scene, which is an empty scene.
  2. RuntimeInitializeOnLoadMethod creates a new monobehaviour gameobject which starts a loading coroutine.
  3. In the loading coroutine:
    a. Create a new empty SimulationRuntime scene (Used for gameobjects created at runtime).
    b. Unload all other scenes.
    c. Additive load Simulation scene using addressables. This is a regular scene with some gameobjects created in the editor. activateOnLoad is set to false. Wait until loaded.
    d. The snippet above is entered to load the entities subscene.
    e. Activate Simulation scene.

It was my understanding that step d would load the entities subscene into the default entities World and it's not really related to the other scenes there.

rustic rain
#

ugh

#

too much scenes

#

I got more problems than solutions from it

cunning bloom
#

Well, most of that shouldn't really matter. Loading an entities subscene should be an isolated step, right?

viral sonnet
#

are you loading a subscene or a scene dynamically? because you should load a scene with a subscene monobehaviour that references the subscene

#

the subscene itself does only exist as serialized data in a build

cunning bloom
#

I'm dynamically loading a subscene. Thanks, I'll look into that.

rotund token
#

netcode ghosts don't support doubles....?

viral sonnet
#

damn i got kind of addicted to generate source code. all my very generalized source that runs on spell data could be turned into specialized source code

#

and it's pretty much the only way how i could get the timings down even more because right now i have 3 sources of slowness. a) target stats b) source stats c) blob data. i could eliminate the blob data but i honestly doubt i would gain that much from it.

errant hawk
#

how do you access a component from a parent entity?

rotund token
#

[Get]ComponentFromEntity

#

or in EntitiesForEach just GetComponent<T>(entity)

errant hawk
#

Im using IJobEntity and I cant seem to find where ComponentFromEntity is. The Parent component doesn't have anything to invoke relating to getting a component.

rotund token
#

ComponentFromEntity is passed in

#

call GetComponentFromEntity on the system

#

and pass it into the job

devout prairie
#

using the mouse hover/pick code from the physics samples, i noticed that they're using shared component to store material references, and i get a non blittable error when trying to do the same thing on a standard component - i take it only shared components allow managed object types?

#

i did kinda wonder why they'd used a shared component for a singleton

errant hawk
errant hawk
rotund token
devout prairie
devout prairie
rotund token
#

is it a class

#

or a struct

#

because you can store managed objects in a class based IComponentData

#

not a struct based IComponentData

devout prairie
#

ahhhhhhh

rotund token
#

public struct UnmanagedComponent : IComponentData
public class ManagedComponent : IComponentData

devout prairie
#

okay thanks

#

does the same apply to a buffer?

rotund token
#

i don't think so

devout prairie
#

trying to store a buffer of materials

rotund token
#

no

devout prairie
#

hmm

rotund token
#

but just store a list

#

on a class icomponentdata

#

not really sure why you'd need a class based dynamic buffer

devout prairie
#

as i say, just trying to store a list of mats

#

and i get the same managed error with buffer

rotund token
#

List<Material>

#

on a IComponentData

devout prairie
#

ahhh ok

rotund token
#

hell

devout prairie
#

so because it's a class IComponentData i can use a list ?

rotund token
#

skip the IComponentData

#

just attached the list to the entity

#

var list = new List<Material>();
EntityManager.AddComponentObject(entity, list);

devout prairie
#

ahhhhhhhhh really

#

i had no idea that was possible

austere pebble
#

DOTS works on 2021 unity?

rotund token
#

0.51 does

#

2021.3.4f1+

austere pebble
#

netcode still death?

rotund token
#

death?

austere pebble
#

I mean if it works also

rotund token
#

netcode works fine

devout prairie
#

tbh i considered just storing this stuff inside system members, rather than the singleton component approach unity have used

#

it's all main thread anyway

#

not sure if there's any benefit to having it on a singleton entity/comp

safe lintel
#

kinda breaks the paradigm of ecs if you store data inside systems

devout prairie
#

i guess so

safe lintel
#

Far easier to access managed component data using entity manager and queries than to be dipping into systems from systems too

cunning bloom
devout prairie
rotund token
cunning bloom
#

Yes, here's the config:

#

"SimulationEntityPrefabs" contains the entities subscene I'm trying to load.

rotund token
#

they aren't your subscenes though correct?

cunning bloom
#

Correct

rotund token
#

have you overridden automatic boot strap?

cunning bloom
#

Nope

errant hawk
#

No matter what I do I cannot get rid of this error: error CS0102: The type 'WheelColliderJob' already contains a definition for '__Rocket_Scripts_ECS_WheelCollider_AsymptotePointTypeHandle'

#

error is caused by the source generator

#

I don't even have a typeHandle anymore

rotund token
#

code?

errant hawk
#

too big to share

#

wait nvm there was a typo for a DynamicBuffer

cunning bloom
rustic rain
errant hawk
#

This works fine:

public partial struct TestForceJob : IJobEntity {
    public void Execute (in PhysicsMass mass, in TestForceData forceData, ref PhysicsVelocity velocity) {
        velocity.ApplyAngularImpulse(in mass, forceData.force);
    }
}

// Seperate file
[GenerateAuthoringComponent]
public partial struct TestForceData : IComponentData {
    public float3 force;
}

But this does not work:

public partial struct TestForceParentJob : IJobEntity {
    public ComponentDataFromEntity<PhysicsVelocity> velocityComp;
    public ComponentDataFromEntity<PhysicsMass> massComp;

    public void Execute (in Parent parent, in TestForceData forceData, in ApplyForceToParentTag tag) {

        if (velocityComp.TryGetComponent(parent.Value, out PhysicsVelocity velocity)) {

            if (massComp.TryGetComponent(parent.Value, out PhysicsMass mass)) {

                velocity.ApplyAngularImpulse(in mass, forceData.force);

                UnityEngine.Debug.Log("Applied force: " + forceData.force);

            } else {
                UnityEngine.Debug.Log("Failed to get PhysicsMass component.");
            }

        } else {
            UnityEngine.Debug.Log("Failed to get PhysicsVelocity component.");
        }
    }
}

// Seperate file
[GenerateAuthoringComponent]
public partial struct ApplyForceToParentTag : IComponentData { }

No exception is thrown, and it does reach the "Applied force:" log so it is working.

#

Here's what the system looks like:

protected override void OnUpdate () {

    //TestForceJob job = new TestForceJob();
    TestForceParentJob job = new TestForceParentJob {
        massComp = GetComponentDataFromEntity<PhysicsMass>(),
        velocityComp = GetComponentDataFromEntity<PhysicsVelocity>()
    };

    job.Schedule().Complete();
}```
rotund token
#

you haven't written the velocity back

#

you are just modifying the local copy of the struct

#
        velocity.ApplyAngularImpulse(in mass, forceData.force);
    }```
this case is passing it in by ref
#

you need to do
velocityComp[parent.Value] = velocity;

#

after you apply changes

errant hawk
#

what a weird way to write the velocity back

rustic rain
#

Just like with entity manager

errant hawk
rotund token
#

can't write an extension with asmref

rustic rain
#

Publicizers rule

rotund token
#

yes thats what i mean

#

you have to write something

#

it's much clearer to just have an extension method to add support

#

which you can do for most things in entities as for the most part everything is marked as internal

#

so it only takes a few seconds to add

rustic rain
# rotund token yeah unfortunately you have to write your own copy as the fields are private
        public T this[Entity entity]
        {
            get
            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                AtomicSafetyHandle.CheckReadAndThrow(m_Safety);
#endif
                var ecs = m_Access->EntityComponentStore;
                ecs->AssertEntityHasComponent(entity, m_TypeIndex);

                CheckComponentIsZeroSized();

                void* ptr = ecs->GetComponentDataWithTypeRO(entity, m_TypeIndex, ref m_Cache);
                UnsafeUtility.CopyPtrToStructure(ptr, out T data);

                return data;
            }

well, tbh all of that is available easily through other means

#

most complex I guess is EntityComponentStore

#

because you don't want EntityManager in jobs

#

yep, feels bad it's private

#

well, one solution I see

#

use publicizer, build assembly

#

load as dll

#

this way it will bypass accessability I think

#

since dlls are not recompiled

errant hawk
# rustic rain ```cs public T this[Entity entity] { get ...

Im really hoping 1.0 will fix all this API garbage that doesn't make much sense. It feels "messy" and overly complicated when it comes down to doing something simple. I can understand the requirements to access the components, that im fine with, but it's everything else that is annoying to work with at times.

rustic rain
#

it's literally language limitations

#

which are quite same in c++

#

what I simply tried to do here: make a hack with pointer

errant hawk
#

plus, that was kinda my point

#

the API in some areas is sloppy, I'm absolutely certain that 1.0 will bring a lot of needed changes to the API the will mentally make more sense. I really dont care if I have to do 3 extra steps to make something work so long as it makes sense doing it

#

Naming conventions is a major aspect of any API. Personally, since a lot of people are going to be familiar with MonoBehaviour, having a similar naming convention for obviously similar components, behaviours, and systems would be best.

rustic rain
#

things that are passed by value are passed by value

#

pointers are not meant to be standard C# workflow

#

they require unsafe context

#

even Unity tried to avoid user from unsafe context

#

by wrapping it all in safe methods

#

with tons of checks

errant hawk
errant hawk
rustic rain
#

it is if you aim for maximum perfomance and you are advanced in C#

#

but I don't find it as a requirment

errant hawk
rustic rain
#

meh

errant hawk
#

maybe not for the developer making a game, but for the library it is

#

I personally prefer using pointers over objects since the logic flow is far more in tune with the logic of how a processor works (linearly)

rustic rain
#

managed logic is part of Unity ECS too

errant hawk
#

yes, and Im perfectly fine with that. Some managed memory on a core aspect of a library is perfectly acceptable

viral sonnet
rustic rain
#

what

#

did you make your own ComponentDataFromEntity? xD

viral sonnet
#

yeah long time ago. can't live without it ๐Ÿ˜„

#

i was begging on the unity forum since i dunno, before 0.17 or smth and they did discuss it internally but then never did bother adding it

errant hawk
viral sonnet
#

yeah they should. i consider the default CDFE implementation pretty trash because it returns a struct copy

#

using the ptr or ref is a pretty substantial increase in performance when you use it for the whole project. also, no copying back needed which results in much nicer code

rustic rain
#

hmmm

#

does your unsafe CDFE assign dependency to system?

#

probably not

viral sonnet
#

it goes through the same checks as CDFE but the EntityManager.GetUnsafeCDFE doesn't add a reader/writer because i didn't bother getting the systemState. the ISystem/Systembase version does though ๐Ÿ˜„

#

i suppose, don't use the entityManager version. i just needed it to write tests

rustic rain
#

internal

#

for systemstate

#
        internal void AddReaderWriter(ComponentType componentType)
        {
            if (CalculateReaderWriterDependency.Add(componentType, ref m_JobDependencyForReadingSystems, ref m_JobDependencyForWritingSystems))
            {
                CompleteDependencyInternal();
            }
        }

this one

viral sonnet
#

i literally just said it did so above and you have the code ๐Ÿ˜„

rustic rain
#

ah

#

I didn't know how it was called until I found it

#

kek

viral sonnet
#

yeah it's a weird method name ๐Ÿ˜„

rustic rain
#

hmmm

#

I wonder what would be better solution

#

own CDFE

#

or hacky extension

viral sonnet
#

i have no idea what you consider a hacky extension. i think the important part it that it'll still be usable after entities updates, easy to integrate and doesn't require any rewrites or local versions of entities

rustic rain
#

so you just access private fields without any regards for it's accessability

viral sonnet
#

i think the answer is pretty obvious if you use words like hacky ๐Ÿ™‚

#

what's the upside of the "hacky extension"?

rustic rain
#

just use native one

viral sonnet
#

you won't get very far with an extension as the fields are private and not internal

rustic rain
#

publicizer makes everything public

viral sonnet
#

publicizer?

rustic rain
#

๐Ÿ˜…

viral sonnet
#

i'm baffled you are even thinking about it ...

rustic rain
#

normally you'd use reflection

#

but publicizing is fast

#

and it's native

viral sonnet
#

feel free to do it. idc ๐Ÿ˜„

gusty comet
#

How could I instantiate a specific entity to a location that a raycast hits? I'm pretty new to DOTS & ECS.

rustic rain
whole gyro
gusty comet
#

Thanks a lot ๐Ÿ™‚ But I guess I gotta learn some of the actual meanings of the stuff used by reading the docs before I start playing with the code.

balmy thistle
#

rarely hurts

errant hawk
#

I honestly dont know what Im doing wrong...

#

just, trying to keep it hovering has been an absolute pain

#

How Im applying force:

velocity.ApplyImpulse(
    massParent[parent.Value],
    translationParent[parent.Value],
    rotationParent[parent.Value],
    local.Up * force.strength,
    local.Position
);
#

What I do not understand is why it's bouncing when the rays are not even making contact with anything. It just bounces without input from the rays

#

console will log when a ray makes contact... multiple times I see it make contact and bounce without the log increasing at all

#

Here's what it looks like hovering (Hasn't made contact with the collider yet, which IMO is causing the bouncing)

solemn hollow
errant hawk
rustic rain
#

if you don't apply force

#

is bouncing present?

errant hawk
rustic rain
#

welp

#

what are you material properties?

#

for both: ground and hover

errant hawk
#

Physics materials?

#

I dont have any templates set atm

rustic rain
#

they are set inlined if you don't give it asset

errant hawk
#

Here's the components the cube has:

rustic rain
#

what about ground

errant hawk
#

Just a physics shape:

rustic rain
#

and what's inside template?

errant hawk
#

Default:

rustic rain
#

do you have any special logic for filters?

errant hawk
rotund token
#

my cubes do not bounce

#

not like tha tnayway

errant hawk
#

Im about ready to give up on ECS and go back to GOs

#

this shit dont work

#

Making a new project with 2021.3.8f to see if there's a difference, otherwise, I will be postponing the usage of ECS until at least 1.0

solemn hollow
#

shot in the dark: but what about that physics step component? maybe you get penetration over multiple physics frames and it adds forces to push out the collider multiple times

#

first time i see that component

errant hawk
#

physics step afaik just syncs it to the fixed update

solemn hollow
#

its in fixed update by default

#

remove the component and see how it behaves

errant hawk
solemn hollow
#

try enabling continuos collision detection

errant hawk
#

@solemn hollow what editor version are you using?

solemn hollow
#

2021.3.6f1

errant hawk
#

same as me atm

errant hawk
solemn hollow
#

i think dynamic + interpolation is CCD

rustic rain
#

smoothing

#

property

#

can you show cube settings?

errant hawk
#

cube is in its own subscene

#

still happens with CCD

#

also tried using a Rigidbody and Box Collider components but same effect

rustic rain
#

have you removed physics step component alltogether?

errant hawk
#

yes

solemn hollow
#

but its not the cube doing the bouncy collision right? its the round shapes

rotund token
#

What's the ground mesh collider

#

Plane collider?

errant hawk
#

yes

#

ill try mesh

rustic rain
#

try box

errant hawk
#

YOOO

#

something's fucked with plane colliders

#

zero issue with convex

#

for the ground plane*

solemn hollow
#

i just tried to replicate your scene. no issues at all

#

plane collider or box collider for ground both works

errant hawk
#

let me try something

errant hawk
rustic rain
#

using scale ๐Ÿค”

errant hawk
#

yeah that is the issue kek

rustic rain
#

and what if you don't scale Z axis

#

or whatever axis that is meant to be 0

solemn hollow
#

all colliders i use have a nonuniform scale too

errant hawk
# solemn hollow no bounce

can you also set Size under the physics Shape to match the size of the plane? I think the issue has to do with the Size property because setting it to 1, 0, 1 works as expected, while having it match the scale causes the bouncing

#

for example, I set the plane to 100x100x100, and the plane Size property to 100x0x100

solemn hollow
#

you mean with the button fit to rendermesh? works for me

errant hawk
#

Ok so

#

why tf did I have Size set to something so large in the first place

errant hawk
solemn hollow
#

i cant reproduce your bounce at all :S

errant hawk
solemn hollow
#

no problems

errant hawk
#

huh weird

#

im going to move the ground outside of the subscene

#

either way it turns out to be the Size property causing the issues. anything greater-than 10 causes the bouncing

solemn hollow
#

my entities are not in a subscene

solemn hollow
errant hawk
#

weird

#

so this might be a isolated issue

solemn hollow
#

@rotund token is burst 1.8.0 pre2 good to use? im still on 1.7.2.

rotund token
#

seems fine

solemn hollow
#

"Setting a breakpoint in an attached managed debugger (Rider/VS Unity Debugger...) on a method that is burst compiled, will switch off the burst code path for that method, allowing it to be debugged as normal." this seems great

errant hawk
solemn hollow
#

T_T

errant hawk
#

is the hybrid renderer required?

rustic rain
errant hawk
errant hawk
#

because in a new project it does the same bouncing

solemn hollow
#

straight down. but i rotated it so it would land flat

errant hawk
#

needs to land on an edge

solemn hollow
#

yes it did land on an edge

errant hawk
#

that's so weird

#

that im the only one with this issue so far

#

brand-new project and editor install as well (2021.3.8f1)

solemn hollow
#

might be time to post in the physics forum.

#

try what happens if you switch to havok

errant hawk
errant hawk
#

my guess is when the cube penetrates the plane, the Size property somehow alters the rate of de-penetration... going to have a look at the sourcecode

jovial mantle
#

hi all, probably been asked before, can you (schedule) instantiate/destroy with C# Jobs ?

solemn hollow
#

with entities you can use commandbuffers to schedule instantiation to a syncpoint in the future. with gameobjects youd need to create a list of all the objects you want to instantiate inside the job and then later outside of the job run through the list and instantiate them

jovial mantle
#

is it possible to use Jobs, (to use another thread) for only this purpose ?

solemn hollow
#

whats your usecase? something that an objectpool cant solve?

jovial mantle
solemn hollow
#

you shouldnt need to care about what thread does which tasks if you use the job system. it just uses as many threads in parrallel as possbile. what you need to care about is how many syncpoints you introduce where jobs need to be finished.

rustic rain
#

make a list

#

add it to job

#

and if you need to destroy smth

#

add it to list

#

after job is completed

#

do whatever you want with that list in managed code

hollow jolt
#

is there a quick way to convert Vector3[] to NativeArray<float3> and back ?

rustic rain
#

no quick

#

I mean, you'd need some unsafe extension for that

#

but it is possible to do very fast conversion between two

#

lol

#

Publicizer crashed PC when I tried to compile

#

attempt #2

#

eh, it won't compile

#

oh wait

#

I know

#

how to make it actually convinient

#

Instead of creating publicized dll extension with useful stuff

#

I can do it with only field that are required for useful stuff

#

basically, just make a extension for every private field that needs to be publicized

#

lemme test whether publicized dll works in editor

#

yep, it works

#

no crashes

viral sonnet
#

that seems so much worse than the asmref trick ...

#

you are not using the lookupcache btw.

#

has to be resolved every time

rustic rain
#

with different return

#

besides

#

I decided to do it differently

#

I will make a library with methods like this

#
        public static void* m_access<T>(this ComponentDataFromEntity<T> cdfe)
            where T : struct, IComponentData
        {
            return cdfe.m_Access;
        }
#

providing access to private fields in different objects

#

through extension methods

#

this way it'll be so much easier to make good extensions

#

without a need to recompile anything

viral sonnet
#

if you go for that, why not publicize the entityComponentStore? just access in cdfe will not be interesting to any other struct

rustic rain
#

I can publicize anything this way

#

but I want to do it through extensions for each field

#

the only problem - I'm struggling to get good reference to Unity API

viral sonnet
#

what happens if you share your library? it won't compile, right?

rustic rain
#

wdym?

#

it can only be compiled with nugget

#

I tried to drop sources to project

#

but Unity does not recognize anything regarding publicized fields

#

I have no idea what's up

#

it won't build anymore xD

#

it did build hour ago

viral sonnet
#

i don't get you, why you are going through this. there's a perfectly valid solution in front of you that has no drawbacks or eleborate setup and is shareable. yet you are wasting time on this. ๐Ÿค”

rustic rain
#

you can't asmref smth that is private and not partial

viral sonnet
#

most private variables are gettable in some other way. i never found a roadblock yet and i've gone balls deep into extensions. yes sometimes you just have to copy parts of unitys code but you need to do that anyway if you are extending.

rustic rain
viral sonnet
#

most important stuff is internal

rustic rain
#

I don't want to reimplement my own cdfe

viral sonnet
#

and the solution is to make something more complicated? the cdfe code is like what, 200 lines?

rustic rain
#

but it's not more complicated

#

it's actually so simple

#

and in case unity will make them internal instead

#

It'll be as easy as just remove old library

#

and fix naming for properties/fields

viral sonnet
#

yet you are not finished yet. i had the cdfe ref done in like half an hour because i was just copying unitys cdfe and adding my methods to it.

rustic rain
#

well, I work kind of slow after actual work xD

viral sonnet
#

and other people can just install the package in their project and done. no nuget or any other dependencies

rustic rain
#

well

#

that's my goal

#

I just build dll

#

and people can just install it in their project

#

and done

#

they can make their own extensions with it

#

using private fields

#

if I would want to add new private fields to it - this is when you need to build with nugget, yes

viral sonnet
#

and that dll has the publicizer in it or how does that work?

rustic rain
#

that dll is already compiled publicized

#

access restrictions exist only in IDE

#

in compiler

#

after it's compiled - it'll work just like that

viral sonnet
#

the publicizer modifies the entities dll, yes?

rustic rain
#

no

#

well, kind of

#

it simply makes everything public

#

all fields, methods, properties

#

so during compilation of dll, you can use it all

#

but it does not modify any actual dll

#

it's only for building

viral sonnet
#

so if i want to use your dll i have to use a modified entities dll?

rustic rain
#

in runtime there is no such thing as private

rustic rain
#

you simply use my dll

#

that's it

#

any idea where can I get a good reference of ECS packages?

#

for Class Library project

#

I don't want to make it inside Unity project

rustic rain
#

so, that's it

#
    public static unsafe ref T AsRef<T>(this ComponentDataFromEntity<T> cdfe, Entity entity)
        where T : struct, IComponentData
    {
        #if ENABLE_UNITY_COLLECTIONS_CHECKS
        AtomicSafetyHandle.CheckReadAndThrow(cdfe.m_Safety());
        #endif
        var ecs = ((EntityDataAccess*)cdfe.m_Access())->EntityComponentStore;
        ecs->AssertEntityHasComponent(entity, cdfe.m_TypeIndex());

        CheckComponentIsZeroSized(cdfe);

        void* ptr = ecs->GetComponentDataWithTypeRW(entity,
            cdfe.m_TypeIndex(),
            cdfe.m_GlobalSystemVersion(),
            ref cdfe.m_Cache());


        return ref UnsafeUtility.AsRef<T>(ptr);
    }

And now I built my own extension method

rustic rain
rotund token
#

Doesn't this just break all conditional code

rustic rain
#

tbh, idk

#

I'll try to build

#

ah yes

#

it is indeed breaks

#

hmm

#

how can I deal with it

#

I guess I can't

#

sucks

rotund token
#

I wasn't even implying builds that's a whole other can of worms

#

I was thinking more things like turning off automatic bootstrap etc

rustic rain
#

feels bad

misty wedge
#

Anyone here have issues with unity using more RAM each time it recompiles? Just trying to rule out experimental burst / dots stuff as the cause... ๐Ÿ˜ฆ

rustic rain
#

hmmm
fixed is only usable on managed objects or?

#

btw, are NativeArrays or other collections pinned in memory or they can be subject of reallocation in heap during defragmentation?

errant hawk
#

How can I update a SystemBase in the equivalent FixedUpdate loop? adding the attribute [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))] throws job dependency errors (trying to write to the same native array)

rustic rain
errant hawk
# rustic rain what kind of dependency errors?
InvalidOperationException: The previously scheduled job Solver:ParallelBuildJacobiansJob reads from the Unity.Collections.NativeArray`1[Unity.Physics.RigidBody] ParallelBuildJacobiansJob.World.CollisionWorld.m_Bodies. You are trying to schedule a new job WheelColliderJob, which writes to the same Unity.Collections.NativeArray`1[Unity.Physics.RigidBody] (via WheelColliderJob.JobData.collisionWorld.m_Bodies). To guarantee safety, you must include Solver:ParallelBuildJacobiansJob as a dependency of the newly scheduled job.
rustic rain
#

looks like you mess up dependency in your OnUpdate

#

mind sharing code?

errant hawk
#

there isn't any dependencies. Just scheduling a IJobEntity in OnUpdate

rustic rain
#

well IJobEntity is subject for dependencies

errant hawk
# rustic rain mind sharing code?
        static RayGizmo[] rays;

        protected override void OnUpdate () {
            NativeList<RayGizmo> rayList = new NativeList<RayGizmo>(4, Allocator.TempJob);

            WheelColliderJob job = new WheelColliderJob {
                velocityParent = GetComponentDataFromEntity<PhysicsVelocity>(),
                translationParent = GetComponentDataFromEntity<Translation>(),
                rotationParent = GetComponentDataFromEntity<Rotation>(),
                massParent = GetComponentDataFromEntity<PhysicsMass>(),

                collisionWorld = World.GetExistingSystem<BuildPhysicsWorld>().PhysicsWorld.CollisionWorld,
                deltaTime = Time.DeltaTime,

                rayDebugger = rayList.AsParallelWriter()
            };

            job.Schedule().Complete();
            rays = rayList.ToArray();
            rayList.Dispose();

            Debug.Log(Time.DeltaTime);
        }
rustic rain
#

every time you access any entity and their components you create a dependency

#

job.Schedule().Complete();

#

doing this in OnUpdate

errant hawk
#

Not supposed to?

rustic rain
#

it is a sync point, at very least

#

that results in more main thread idling

#

but you also

#

when you Schedule

#

you don't write Dependency

#

to it

#

so what happens

#

is that it simply runs

viral sonnet
rustic rain
#

and Unity notices it and shouts at you for that

#

meanwhile during that moment, some other jobs can access component data you requested

#

Schedule(Dependency)

#

would probably solve it

viral sonnet
#

yeah, and additonaly schedule with Dependency

errant hawk
viral sonnet
#

but first you have to register the dependency with the code i posted

errant hawk
#

yeah let me try it

rustic rain
#

World.GetExistingSystem<BuildPhysicsWorld>()
๐Ÿค”

viral sonnet
#

there's also readWrite to adjust accordingly

viral sonnet
errant hawk
errant hawk
rustic rain
#

if you only read them

#

and assign readonly attributes to fields in job

errant hawk
#

I've set everything else to readonly

#

idk how else I'm supposed to apply a force to a rigidbody

rustic rain
#

so

#

how your attributes look?

#

for system

errant hawk
#

Just this: [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]

rustic rain
#

๐Ÿค”

errant hawk
#

should I specify an after as well?

rustic rain
#

try to add

#

hmm

#

what is it called

#

in world system

#

AddInputDependency

#

or smt hlike that

#

oh wait

#

you still do Complete

#

right?

errant hawk
rustic rain
#

add

#

UpdateAfter( ExportPhysics...

#

just make sure

#

your system runs

#

after physics step is fully done

#

near FixedStep ECB

errant hawk
#

so many weird requirements to get something to just update in fixed lol

#

Like, I understand what they're doing

worn walrus
#

do u know how to make an ai to follow you

#

i am dumb

rustic rain
#

you need to know where your systems need to be called

errant hawk
rustic rain
#

it relies on constraints

#

not on some list with priorities

errant hawk
#

you can still have constraints if it was done through the editor

#

instead of specifying the attribute, you just add it to a group and set its order accordingly in the editor

rustic rain
#

eh

#

I don't favour such approach, because it won't support modding very well

errant hawk
#

you can still have attributes

#

it's just to visualize it and manage it the editor approach is better

rustic rain
#

but it's already visualized

#

when you create new system you simply just figure where it needs to be

#

kek

#

assuming you assign order as soon as you create system

errant hawk
#

there's nothing to reference it after

rustic rain
#

most of the time

#

you don't care about the order

#

so you just let Unity do it

#

and when you do care, you probably know where it needs to be

errant hawk
#

well see, when working on prediction and networking it is absolutely critical you have full control over the order of execution.