how could i know if it run correctly with linux server no graphic

Discuss any questions about BEPUphysics or problems encountered.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

Thank you norbo.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

My client and server are unsync. It walk with difference velocity. My client is faster. Client use Unity. And Sever is use updateCharacterGoal.
I send bepu target and speed back to client. And then make character move.
But in bepu I make it send position back as foot print.

Here are my thread code

Code: Select all

void PoolThread()
        {
            var deltaTime = 0.015f;
            var sleepTime = (int)(deltaTime * 1000);
            while (true)
            {
                simulation.Timestep(deltaTime, threadDispatcher);
                foreach (var pair in walkCharacters)
                {
                    var character = pair.Value;
                    if (character.CalculateMagnitude() > 0.5)
                    {
                        var distant = character.CalculateDistant();
                        if (distant > 0.2)
                        {

                            if (!character.IsCalculateVelocityYet)
                            {
                                character.CalculateVelocity();
                            }
                            //charac.MunipulateVelocity();
                            character.CharacterInputt.UpdateCharacterGoals(character.Velocity, character.MoveSpeed, [color=#FF4000]sleepTime[/color]);
                            character.InstantMove();
                        }
                        else
                        {
                            walkRemoveCharacters.Add(character.collider.bodyHandle);
                        }
                    }
                }
                foreach (var handle in walkRemoveCharacters)
                {
                    if (walkCharacters.ContainsKey(handle))
                    {
                        walkCharacters.Remove(handle);
                        //simulation.Bodies.Remove(handle);
                        //handleUnits.Remove(handle);
                    }
                }
                walkRemoveCharacters.Clear();
                if (isStop)
                {
                    break;
                }
                Thread.Sleep(sleepTime);
            }
        }
First i use sleep time but it seem slow at UpdateCharacterGoals. After that I try deltatime but it is slower.
So I try this

Code: Select all

void PoolThread()
        {
            while (true)
            {
                foreach (var pair in walkCharacters)
                {
                    var character = pair.Value;
                    if (character.CalculateMagnitude() > 0.5)
                    {
                        var distant = character.CalculateDistant();
                        if (distant > 0.2)
                        {

                            if (!character.IsCalculateVelocityYet)
                            {
                                character.CalculateVelocity();
                            }
                            character.CharacterInputt.UpdateCharacterGoals(character.Velocity, character.MoveSpeed, deltaTime);
                            character.InstantMove();
                        }
                        else
                        {
                            walkRemoveCharacters.Add(character.collider.bodyHandle);
                        }
                    }
                }

                foreach (var handle in walkRemoveCharacters)
                {
                    if (walkCharacters.ContainsKey(handle))
                    {
                        walkCharacters.Remove(handle);
                        //handleUnits.Remove(handle);
                    }
                }
                walkRemoveCharacters.Clear();
                if (isStop)
                {
                    break;
                }
                Simulation.Timestep(deltaTime, threadDispatcher);
            }
        }
Program seem do nothing. I think because of it is rapid fire.

I have another question what is thread dispatcher?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how could i know if it run correctly with linux server no graphic

Post by Norbo »

Thread.Sleep will sleep at least as long as the input value, but is not guaranteed any level of precision beyond that. The resolution depends upon the operating system. On windows, I believe the default resolution is 15.625ms, so you're dealing with very coarse timing. It's possible to force higher resolution, and it's possible to use Thread.Sleep(1) if you know you need to sleep a duration longer than the sleep resolution to help skip some time, but for significant precision you generally need a busy loop. (To make it a little friendlier, you can use Thread.Yield and Thread.Sleep(0) to schedule different sets of waiting threads.)

On top of that, it's not enough to simply wait a fixed delta time between updates, since the update itself could take time. To know how much longer you need to wait, you have to measure how long it's actually been since the start of the last update. Stopwatch.GetTimestamp/Stopwatch.Frequency can give you reasonably precise measurements.
I have another question what is thread dispatcher?
It's the interface that bepuphysics uses to launch threads for multithreading internally. It should launch a number of threads equal to the number of workers you want to use- the engine handles job scheduling internally.

If you don't want to use multithreading internally, you can just not pass a thread dispatcher into the simulation.Timestep function.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

Thank you.
On top of that, it's not enough to simply wait a fixed delta time between updates, since the update itself could take time. To know how much longer you need to wait, you have to measure how long it's actually been since the start of the last update. Stopwatch.GetTimestamp/Stopwatch.Frequency can give you reasonably precise measurements.
You mean i can find fixed time by Stopwatch.GetTimestamp/Stopwatch.Frequency. Is this will get me delta time right?
Or you mean I have to use that every thread frame.(Use it inside thread)

After I make more dt the faster it walk after 6 it walk faster than unity

Code: Select all

 simulation.Timestep(deltaTime, threadDispatcher);
Is this code tell bepu deltatime?
What I have to put in this deltatime?


What is delta time I have to put in update character goals
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how could i know if it run correctly with linux server no graphic

Post by Norbo »

Or you mean I have to use that every thread frame.(Use it inside thread)
Yes, in order to wait the correct amount of time, you must constantly be measuring how much longer you have to wait:
measuredwaiting.png
measuredwaiting.png (7.99 KiB) Viewed 20167 times
Is this code tell bepu deltatime?
What I have to put in this deltatime?
The simulation itself should operate on a fixed timestep- choose a constant value ahead of time. After that much time has elapsed (as measured in the waiting loop) since the start of the previous update, you trigger another timestep with that constant timestep duration.

UpdateCharacterGoals needs the same fixed timestep duration.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

Thank you.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

I'm made stand alone version after not understand where I miss. Now this stand alone also use as it is in project. I don't know why it is slow.
Help me please.
Thank you.
:D :D :D

https://github.com/parapoohda/testBepu

I only make it move forward. And It is base on character demo.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how could i know if it run correctly with linux server no graphic

Post by Norbo »

The CharacterControllers system itself is not being used, so the only thing active is the CharacterControllerInput air control. The CharacterControllers needs to be hooked up like in the original demos.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

Oh I have to look into it. Thank you.

It seem after use character demo callback it is walkable.
But I want to make online game can All character share same character controller?

Update
I seem i am silly. I think character controller is for one character. But after I share character control It move(I move 2 character with different direction).
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how could i know if it run correctly with linux server no graphic

Post by Norbo »

An individual CharacterController is indeed only for a single character and should not be shared, but the CharacterControllers system is designed to handle all the characters in the simulation.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

Thank you. I didn't notice there are character control with and without s.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

It try to use broad phase to tell which unit is near player. So I don't have to send every thing in bufferpool(game map) to client.
but I think broad phase work incorrectly with static.But it work fine with dynamic.
Can I use broadphase to see static object too.
Maybe because I use handle to refer to my custom object. Because first static and first dynamic share same handle (Not sure). So it break.

Is broadphase can sense static?
Is dynamic and static object can share same handle?

thank you :D :D :D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how could i know if it run correctly with linux server no graphic

Post by Norbo »

Is broadphase can sense static?
Is dynamic and static object can share same handle?
Yes to both. The broad phase reports CollidableReference instances which have a Mobility property that can be used to distinguish between bodies and statics.

Note that the handle and mobility flag are packed into the CollidableReference.Packed field, so it could serve as a simulation-wide unique collidable identifier if you want.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: how could i know if it run correctly with linux server no graphic

Post by parapoohda »

Thank you. You're very helpful.
Post Reply