x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

When creating a new mesh section in the ProceduralMeshComponent, all existing sections with higher index are removed

Branch: Binary build from the Unreal Launcher.

Build version: Version: 4.8.1-2591939

Description: When calling the CreateMeshSection function (with the argument "SectionIndex") in the new ProceduralMeshComponent, the section array is resized to "SectionIndex+1". This has the effect, that all existing sections with higher index than "SectionIndex" are deleted. I guess that is not intended.

Repro Steps

Action 1: Create new ProceduralMeshComponent

Action 2: Create mesh section with index 1, then create mesh section with index 2

Action 3: Update/create mesh section with index 1 (this will delete section 2)

Product Version: UE 4.8
Tags:
more ▼

asked Jul 08 '15 at 08:21 PM in C++ Programming

avatar image

mkroeter
11 2 3 6

avatar image Adam Davis STAFF Jul 10 '15 at 02:51 PM

Does this occur in a clean, blank project with no additional content or is this limited to a specific project? How are you setting the mesh indexes? Can you show me a screenshot of your blueprint setup?

avatar image mkroeter Jul 10 '15 at 03:05 PM

This occurs in a clean project. I set up the mesh just using C++ with the CreateMeshSection(...) function. I call this function every second (using Tick(...)) with a different section index in order to update the corresponding mesh part.

If I have three mesh sections: 1st sec -> update section 0, 2nd sec -> update section 1, 3rd sec -> update section 2, 4th sec -> update section 0 (This will delete sections 1 and 2)

avatar image mkroeter Jul 11 '15 at 11:06 AM

I compiled the engine from source now and added a range check to CreateMeshSection. Before resizing the ProcMeshSections array, I just check if the section index is bigger than the current array size. This solves the problem.

avatar image Doug E ♦♦ STAFF Jul 15 '15 at 02:53 PM

Hey mkroeter-

Could you elaborate on your repro steps? After creating a new class based on ProceduralMeshComponent how exactly are you creating the mesh sections? Can you post the code that you used with your repro steps?

avatar image mkroeter Jul 21 '15 at 05:05 PM

Hi, sorry I dont have access to the code I used at the moment, but I think you can just create 5 sections with just one triangle, where the triangle is shifted in each section. Then update the first section again in the last step. Only the first section will remain.

Create a new class based on AActor and add a procedural mesh component as a member variable. After creating this mesh component:

 for (int i=0; i<5; i++) {
     TArray<FVector> vertices;
     TArray<int32> faces;
     vertices.Add(FVector(0,0, i * 100));
     vertices.Add(FVector(100,0, i * 100));
     vertices.Add(FVector(100,100, i * 100));
     faces.Add(0);
     faces.Add(1);
     faces.Add(2);
     ProcMeshComponent->CreateMeshSection(i, vertices, faces, TArray<FVector>(), TArray<FVector2D>(),  TArray<FColor>(), TArray<FProcMeshTangent>(), false);
 }
 
 TArray<FVector> vertices;
 TArray<int32> faces;
 vertices.Add(FVector(0,0, 0));
 vertices.Add(FVector(100,0, 0));
 vertices.Add(FVector(100,100, 0));
 faces.Add(0);
 faces.Add(1);
 faces.Add(2);
 ProcMeshComponent->CreateMeshSection(0, vertices, faces, TArray<FVector>(), TArray<FVector2D>(),  TArray<FColor>(), TArray<FProcMeshTangent>(), false);

I can verify if the problem also happens with this code tomorrow.

Edit: Yes, it happes with this example as well

avatar image Doug E ♦♦ STAFF Jul 22 '15 at 04:30 PM

What function are you adding the for() loop to? Is this being done inside the constructor or begin play or another function? Are you using the for() loop as well as repeating the code outside the loop? Let me know if you're also able to reproduce this in a new project.

avatar image Doug E ♦♦ STAFF Jul 28 '15 at 03:50 PM

Hey mkroeter-

Where is this for loop being added? Is this going inside the constructor of the actor or in another function? Are you using both the for loop as well as the lines posted after (which appear to be the same code without the loop)?

avatar image mkroeter Jul 29 '15 at 02:50 PM

Hi, yes I use both the loop and the lines after it. As I said, I update the first section again at the end, that is why I have the same code again after the loop. You can put this code anywhere, I have it in BeginPlay.

avatar image Doug E ♦♦ STAFF Jul 21 '15 at 04:04 PM

Hey mkroeter-

We've not heard from you in a couple days. I will be marking this post as resolved for tracking purposes, however if you're still having any issues with ProceduralMeshComponent please feel free to respond with the information requested and we will continue to investigate.

Cheers

Doug Wilson

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey mkroeter-

The issue seems to be that the scope of the arrays is not being considered. When the loop is entered the first time it will create the vertices and faces arrays. Because they only exist inside the loop, each iteration of the loop will recreate both arrays. The arrays are again recreated once the loop exits. Moving the first two lines of the loop to before the loop is called and removing the first two lines after the loop completely should solve the problem.

Cheers

Doug Wilson

more ▼

answered Jul 30 '15 at 03:46 PM

avatar image mkroeter Jul 31 '15 at 08:23 AM

Hi, isn't the content of these arrays copied in CreateMeshSection? And why is it working when I dont add the lines after the loop? In this case sections 0-4 are rendered correctly. Anyway as I already wrote above I fixed the problem for me by adding a range check to the CreateMeshSection code (before resizing the sections array). I just wrote it here that you are aware of that, I will not investigate this problem further. Cheers, Manuel

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question