Announcement

Collapse
No announcement yet.

Async creation of ProceduralMeshComponent

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Async creation of ProceduralMeshComponent

    How to create a PMC mesh in a async thread?
    I'm trying FRunnable but get an assertion.
    Cant find any examples online.

    #2
    hard to tell without knowing the code and the error.

    Comment


      #3
      Try looking for examples of procedural mesh component and Runnable threads separately. Unreal Wiki is quite useful there.

      Comment


        #4
        Originally posted by DonFrag View Post
        hard to tell without knowing the code and the error.
        Well the thing is the Unreal does not give me information either. Maybe people here have some examples.
        What i do is i create a FRunnable

        something like:
        Code:
        class MyRun : public Frunnable
        {
        UProceduralMeshComponent* pmc;
        ...
        void Run()
        {
         pmc ->CreateMeshSection(...); //here breaks exception
        }
        }

        Comment


          #5
          Originally posted by Fieol View Post
          Try looking for examples of procedural mesh component and Runnable threads separately. Unreal Wiki is quite useful there.
          I don't know about that. Couldn't find anything useful there.

          Comment


            #6
            These two are complex topics, so having a tutorial which has both of them implemented, is a luxury to ask, but I'm sure if you dig well enough you can find some code snippets or references.
            For now I have links of wiki for procedural mesh and multi-threading separately.

            Comment


              #7
              did you check if pmc is null?

              Originally posted by YanDaik View Post

              Well the thing is the Unreal does not give me information either. Maybe people here have some examples.
              What i do is i create a FRunnable

              something like:
              Code:
              class MyRun : public Frunnable
              {
              UProceduralMeshComponent* pmc;
              ...
              void Run()
              {
              pmc ->CreateMeshSection(...); //here breaks exception
              }
              }

              Comment


                #8
                This is the way you initialize the Thread.

                Code:
                //***********************************************************
                //Thread Worker Starts as NULL, prior to being instanced
                //        This line is essential! Compiler error without it
                FTaskCreateStreets* FTaskCreateStreets::Runnable = NULL;
                //***********************************************************

                Comment


                  #9
                  Originally posted by DonFrag View Post
                  did you check if pmc is null?


                  Yes i did.
                  I've seen mention that you can create any UObjects or actors in any other thread than main thread.
                  Probably that is the problem.
                  Any ideas how to call function on main thread form a Runnable?

                  Comment


                    #10
                    Originally posted by Fieol View Post
                    This is the way you initialize the Thread.

                    Code:
                    //***********************************************************
                    //Thread Worker Starts as NULL, prior to being instanced
                    // This line is essential! Compiler error without it
                    FTaskCreateStreets* FTaskCreateStreets::Runnable = NULL;
                    //***********************************************************
                    Thanks for help, dude. But thread is fine.

                    Comment


                      #11
                      Originally posted by YanDaik View Post
                      Yes i did.
                      I've seen mention that you can create any UObjects or actors in any other thread than main thread.
                      Probably that is the problem.
                      Any ideas how to call function on main thread form a Runnable?
                      TFuture<void > future=Async (EAsyncExecution::Thread, [&]()
                      {

                      //run code in different thread

                      Async(EAsyncExecution::TaskGraphMainThread, [&]
                      {
                      ChangeGameState(EGameStatus::GAMEPLAY);//callit on game thread

                      });



                      });

                      Comment


                        #12
                        Code:
                        TFuture<void > future=Async (EAsyncExecution::Thread, [&]()
                        {
                        
                        //run code in different thread
                        
                        Async(EAsyncExecution::TaskGraphMainThread, [&]
                        {
                        ChangeGameState(EGameStatus::GAMEPLAY);//callit on game thread
                        
                        });
                        
                        
                        
                        });

                        Comment

                        Working...
                        X