Announcement

Collapse
No announcement yet.

Generate Procedural Mesh

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

    #61
    I can now confirm that, no, the dynamic mesh collision code has not yet been put in place / that issue is not fixed.

    Which does mean we can't yet have collision for dynamic meshes in fully packaged games.

    Epic please address this soon as you can!

    Thanks!



    Rama
    100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

    Comment


      #62
      Originally posted by Rama View Post
      I can now confirm that, no, the dynamic mesh collision code has not yet been put in place / that issue is not fixed.

      Which does mean we can't yet have collision for dynamic meshes in fully packaged games.

      Epic please address this soon as you can!

      Thanks!



      Rama
      It's still slated for June, although more people should vote for it...
      It is by will alone I set my code in motion.
      It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
      It is by will alone I set my code in motion.

      Comment


        #63
        Hey everyone,

        Thank you for this awesome thread and the work you've been sharing.

        I've currently run in to a snag and I'm wondering if anybody else is having the same problem. If I create a blueprint to run line traces agaisnt the dynamic meshes I'll eventually get the following crash:

        Code:
        !Id:9807dac3b980b09e7b3092cc6049391b
        
        Access violation - code c0000005 (first/second chance not available)
        
        UE4Editor-Engine.dll
        
        UE4Editor_Engine + 11365999 bytes
        UE4Editor_Engine + 11246153 bytes
        UE4Editor_Engine + 11609624 bytes
        UE4Editor_Engine + 11566745 bytes
        UE4Editor_Engine + 4733635 bytes
        UE4Editor_Engine + 4734271 bytes
        UE4Editor_Engine + 21294089 bytes
        UE4Editor_CoreUObject + 1314781 bytes
        UE4Editor_CoreUObject + 1371986 bytes
        UE4Editor_CoreUObject + 1457175 bytes
        UE4Editor_CoreUObject + 1377083 bytes
        UE4Editor_CoreUObject + 1316120 bytes
        UE4Editor_CoreUObject + 1377083 bytes
        UE4Editor_CoreUObject + 1375095 bytes
        UE4Editor_Engine + 1765263 bytes
        UE4Editor_Engine + 15382955 bytes
        UE4Editor_Engine + 6018158 bytes
        UE4Editor_Engine + 6012290 bytes
        UE4Editor_Engine + 6055406 bytes
        UE4Editor_Engine + 1656563 bytes
        UE4Editor_Engine + 8617942 bytes
        UE4Editor_Engine + 8688548 bytes
        UE4Editor_Core + 462146 bytes
        UE4Editor_Core + 462589 bytes
        UE4Editor_Core + 524839 bytes
        UE4Editor_Engine + 9015033 bytes
        UE4Editor_Engine + 8917088 bytes
        UE4Editor_Engine + 8960756 bytes
        UE4Editor_Engine + 5129510 bytes
        UE4Editor_Engine + 5156650 bytes
        UE4Editor_UnrealEd + 1464870 bytes
        UE4Editor_UnrealEd + 5375494 bytes
        UE4Editor!FEngineLoop::Tick() + 3555 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\launchengineloop.cpp:2091]
        UE4Editor!GuardedMain() + 476 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\launch.cpp:132]
        UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\windows\launchwindows.cpp:125]
        UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.2\engine\source\runtime\launch\private\windows\launchwindows.cpp:207]
        UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]

        I've confirmed that in other projects without the dynamic mesh instances that I cannot reproduce the crash. I've attempted to debug the issue by running the engine from VS with debugging on, however instead of a break it simply freezes and crashes to desktop. I'd be grateful if someone else who's implemented the dynamic meshes would try and run a few line traces to see if they see the same thing. Otherwise it might be something on my side unrelated to the dynamic meshes. Here is my blueprint for reference:

        http://gyazo.com/f8224ab23c3d823e02f5c552ee3a5439

        The trace will fire and show up on the meshes a few times but eventually crash. Sometimes it crashes early other times I have to spam it about 20-30 times to get it to crash.

        Thanks.

        Comment


          #64
          Ok, I've got a pretty good lead on my problem. I seem to have found a solution that works for me, but I don't think it's really 100% correct.

          The crash was being caused from the following location in the engine in the SetHitResultFromShapeAndFaceIndex() function in Source\Runtime\Engine\Private\Collision\CollisionConversions.cpp
          Code:
          			// @fixme: only do this for InGameThread, otherwise, this will be done in AsyncTrace
          			if ( IsInGameThread() )
          			{
          				// This function returns the single material in all cases other than trimesh or heightfield
          				PxMaterial* PxMat = PShape->getMaterialFromInternalFaceIndex(FaceIndex);
          				if(PxMat != NULL)
          				{
          					OutResult.PhysMaterial = FPhysxUserData::Get<UPhysicalMaterial>(PxMat->userData);
          					FString name = OutResult.PhysMaterial->GetName();
          				}
          			}
          			else
          			{
          				//@fixme: this will be fixed properly when we can make FBodyInstance to be TWeakPtr - TTP (263842)
          			}
          For certain FaceIndex the PxMat pointer returned from getMaterialFromInternalFaceIndex() would be garbage data (0xddddddddd...), this caused the deference PxMat->userData to crash the editor. It seems that for certain face indies we're not setting the correct "Physics Material"...

          After poking around in the GeneratedMeshComponent.cpp I found this (added comment to the suspicious line..)
          Code:
          bool UGeneratedMeshComponent::GetPhysicsTriMeshData(struct FTriMeshCollisionData* CollisionData, bool InUseAllTriData)
          {
          	FTriIndices Triangle;
          
          	for (int32 i = 0; i<GeneratedMeshTris.Num(); i++) {
          		const FGeneratedMeshTriangle& tri = GeneratedMeshTris[i];
          
          		Triangle.v0 = CollisionData->Vertices.Add(tri.Vertex0.Position);
          		Triangle.v1 = CollisionData->Vertices.Add(tri.Vertex1.Position);
          		Triangle.v2 = CollisionData->Vertices.Add(tri.Vertex2.Position);
          
          		CollisionData->Indices.Add(Triangle);
          		CollisionData->MaterialIndices.Add(i); //Why are we setting the Material index to the index of the triangle?
          	}
          
          	CollisionData->bFlipNormals = true;
          
          	return true;
          }
          After using the static mesh as a reference: https://docs.unrealengine.com/latest...ata/index.html
          It looks like this should be the "index of the material" and not the index of the triangle. My guess is we're looking for materials at indexies that don't exist.

          Changing the line:
          Code:
          CollisionData->MaterialIndices.Add(i);
          To this:
          Code:
          CollisionData->MaterialIndices.Add(0);
          Seems to have solved the crashing issue. I've probably broken material-based physics collision but since I don't need that for now I'm going to work with this. Hopefully someone who knows more about this stuff than me can figure out what the proper fix is.

          Comment


            #65
            Originally posted by Rama View Post
            I can now confirm that, no, the dynamic mesh collision code has not yet been put in place / that issue is not fixed.

            Which does mean we can't yet have collision for dynamic meshes in fully packaged games.

            Epic please address this soon as you can!

            Thanks!



            Rama
            Dear Epic / James G,

            Any update on the adding of Cooked Collision for the Dynamic Mesh Component?

            It would be incredibly useful for so very many projects to have cookable collision for dynamically generated meshes!

            Thanks!

            Rama
            100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

            Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

            Comment


              #66
              Hi,

              I recently started on UDK to get a render of a procedural generation library. I tried to follow instructions on wiki but i get errors as i miss to link somethings. I suppose some obvious mistake from me but as i don't dev in c++ long time ago, i'm appreciate some help.

              Here the errors : http://pastebin.com/uYekB2eZ

              Comment


                #67
                Hi HellFiveday,

                Please make this a post on the answerhub at http://answers.unrealengine.com so we can track this and provide assistance. Thank you!
                Adam Davis | Marketplace Support | Epic Games
                How to report a bug? | Installation & Setup issues? | Answerhub Bug Reports | Twitter

                Comment


                  #68
                  I think it's more easy to provide solution in the same post. Anyway i found my misstake, i use the version 4.3.0 and the code provided require 4.2.1.

                  Comment


                    #69
                    Originally posted by HellFiveDay View Post
                    I think it's more easy to provide solution in the same post. Anyway i found my misstake, i use the version 4.3.0 and the code provided require 4.2.1.
                    I won't be back to work on this before a couple of weeks, but I'll update the wiki once I get my stuff up to date.
                    It is by will alone I set my code in motion.
                    It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
                    It is by will alone I set my code in motion.

                    Comment


                      #70
                      In case anyone's still fooling around with this tutorial, I've added a better CalcBounds(). It now seems to give you the same bounds as other meshes.

                      Comment


                        #71
                        Hi,

                        I am having an issue with this, I created a very simple mesh which is just a flat plane made from 4 triangles. The issue I am having is when using one of the starter textures the M_cobblestone_rough. The problem is when I move the camera left and right while looking down on the texture the bumpmap is changing the material like I am moving the camera in a different direction, up\down.

                        I tracked it down to the tangents in this part of the code:-

                        Code:
                        GeneratedMeshComponent.cpp
                        
                        
                        			const FVector Edge01 = (tri.Vertex1.Position - tri.Vertex0.Position);
                        			const FVector Edge02 = (tri.Vertex2.Position - tri.Vertex0.Position);
                        
                        			const FVector TangentX = Edge01.SafeNormal();
                        			const FVector TangentZ = (Edge02 ^ Edge01).SafeNormal();
                        			const FVector TangentY = (TangentX ^ TangentZ).SafeNormal();
                        If I change this to:-
                        Code:
                        			const FVector TangentX = FVector(1, 0, 0);
                        			const FVector TangentZ = FVector(0, 0, 1);
                        			const FVector TangentY = FVector(0, 1, 0);
                        It looks a bit odd, but its at least moving correctly.

                        So question is am I doing something wrong or is this not the correct way to calculate the tangents? if needed I can record a short vid of the problem as its not that easy to explain.

                        Thanks
                        Last edited by Threap; 08-21-2014, 01:06 PM.

                        Comment


                          #72
                          Hi guys,

                          I've been following this thread and I managed to create a lot of geometry with collisions and textures so, THANKS A LOT!

                          I'm now stuck because I want to modify the mesh and collision at runtime, any idea about how can I achieve that?

                          I've been trying to delete and rebuild (with new data) the content of the GeneratedMeshComponent, but it doesn't seem to have any effect in game.

                          Thanks a lot!

                          Comment


                            #73
                            Originally posted by Eclipsed View Post
                            Hi guys,

                            I've been following this thread and I managed to create a lot of geometry with collisions and textures so, THANKS A LOT!

                            I'm now stuck because I want to modify the mesh and collision at runtime, any idea about how can I achieve that?

                            I've been trying to delete and rebuild (with new data) the content of the GeneratedMeshComponent, but it doesn't seem to have any effect in game.

                            Thanks a lot!
                            You need to call MarkRenderStateDirty from the component when you update any values to ensure that the Scene Proxy gets rebuilt with your new data.
                            FluidSurface Plugin: https://github.com/Ehamloptiran/UnrealEngine/releases
                            TextureMovie Plugin: https://github.com/Ehamloptiran/TextureMoviePlugin

                            Comment


                              #74
                              Well, I do call UGeneratedMeshComponent::SetGeneratedMeshTriangles which marks the render state as dirty.

                              I'll double-check when I'll go back home, but I'm pretty sure I did that.

                              Btw, would this affect the collisions as well?

                              Comment


                                #75
                                Originally posted by Ehamloptiran View Post
                                You need to call MarkRenderStateDirty from the component when you update any values to ensure that the Scene Proxy gets rebuilt with your new data.
                                My bad, the code is correct and there's nothing special to do.

                                I had some stale code rebuilding the original mesh right after the code I use to modify it, thus voiding any modification

                                Sorry if I wasted you time

                                Comment

                                Working...
                                X