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"

Why GetArrayView is null in standalone?

Hello,

I have a raycast code which works perfectly in Editor builds (DebugGame Editor and Development Editor) but crashes in modes without editor.

example:

     const auto* Actor = RV_Hit.GetActor();
     UStaticMeshComponent* HitStaticMeshComponent = Cast<UStaticMeshComponent>(RV_Hit.Component.Get());

     if (HitStaticMeshComponent)
     {
         UStaticMesh* StaticMesh = HitStaticMeshComponent->StaticMesh;
         FStaticMeshLODResources& LODModel = StaticMesh->RenderData->LODResources[0];
         FIndexArrayView Indices = LODModel.IndexBuffer.GetArrayView();

this is a raycast/hit check code fragment. Indices is correct in editor modes, but NULL in standalone modes, therefore crashes in next lines where I want access it.

What I need to set/add in C++ for getting it work in standalone modes?

thanks, Gabor

Product Version: Not Selected
Tags:
more ▼

asked Nov 05 '14 at 10:57 AM in Bug Reports

avatar image

BigaCubensis
115 6 78 22

avatar image BigaCubensis Nov 05 '14 at 07:27 PM

new info:

the following boolean seems controls this:

 bool bNeedsCPUAccess = !FPlatformProperties::RequiresCookedData();

tooltip shows that GetArrayView is only valid when bNeedsCPUAccess is true.

and it is confirmed, there is diff:

standalone:

 + LODModel.IndexBuffer {IndexStorage={bNeedsCPUAccess=**false** } b32Bit=false } FRawStaticIndexBuffer

editor:

 + FIndexBuffer {IndexBufferRHI={Reference=0x000000000f8405d0 <Information not available, no symbols loaded for UE4Editor-D3D11RHI.dll> } } FIndexBuffer
 + IndexStorage {bNeedsCPUAccess=**true** } TResourceArray<unsigned char,0>
 b32Bit false bool

so the exact question is, how can I set this variable true for standalone?

avatar image Niktsuki Nov 06 '14 at 10:23 PM

Anyone with a solution for this?

avatar image BigaCubensis Nov 09 '14 at 12:10 PM

well maybe this is also an important info: seems not only the mentioned boolean bNeedsCPUAccess is the problem, in standalone the entire IndexBuffer is NULL for that LOD. seems in standalone there is no initialisation for that buffer, therefore GetArrayView returns also with NULL (which works from IndexBuffer) it is quite strange, as many UE sources use that method, and as I see, not only Editor related sources.

avatar image Tim C ♦♦ STAFF Nov 10 '14 at 10:03 PM

Hi BigaC,

Could you provide some additional information about this issue?

  • What version of the Engine are you using?

  • Are you using the binary version of the Engine installed by the Launcher, or did you build the Engine from source code?

  • Does this happen only in your own project, or are you able to reproduce this in a new project? If so, could you provide the steps you are following to cause the crash to occur?

  • Can you provide the callstack and logs after the crash occurs?

Please see this page for any additional information that may be helpful.

avatar image BigaCubensis Nov 10 '14 at 11:01 PM

Hello,

Thanks for the reply. Im using UE 4.4.3, but I had the same problem with previous versions (from 4.3.1). It is the binary version. Callstack, logs attached. link text alt text link text

The crash occurs at the line when I want access the indexbuffer of my LOD resource:

     if (HitStaticMeshComponent)
     {
         UStaticMesh* StaticMesh = HitStaticMeshComponent->StaticMesh;
         FStaticMeshLODResources& LODModel = StaticMesh->RenderData->LODResources[0];
         
         FIndexArrayView Indices = LODModel.IndexBuffer.GetArrayView();
         
         const FPositionVertexBuffer& PositionVertexBuffer = LODModel.PositionVertexBuffer;

     >>>>    int32 Index0 = Indices[RV_Hit.FaceIndex * 3];


This source works well if I start the game with editor build (DebugGame Editor), ut doesnt work if I start it as standalone (DebugGame). The buffer is ok in the editor modes, but NULL in standalone (see Watch screen), so accessing it by index fails.

The mesh Im using for raycast is the standard UE sphere: StaticMesh'/Game/Shapes/EditorSphere.EditorSphere

Im working in a small team, two other people has UE, and they experience the same crash on same line.

spiritslog.zip (7.6 kB)
callstack.txt (3.0 kB)
debuginfo.png (93.7 kB)
avatar image BigaCubensis Nov 11 '14 at 06:27 AM

I try to check it in a new project, though it isnt so easy, but probably I can do it with a simpler code today.

avatar image BigaCubensis Nov 11 '14 at 06:59 PM

Repro steps for crash:

  1. Create new C++ project: Code First Person, name as RayCastTest

  2. Add Source Code from UE menu, select Player Controller as base class, name MyPlayerController

  3. Edit sources with VS and add RHI, RenderCore to RayCastTest.Build.cs file

  4. Replace MyPlayerController.h and MyPlayerController.cpp with attached sources

  5. Add following lines to RayCastTestGameMode.cpp: include "MyPlayerController.h", to the constructor: PlayerControllerClass = AMyPlayerController::StaticClass();

  6. Start project with editor build

  7. Open level blueprint and add raycast to mouse click according to attached screen save

  8. Make breakpoint to line 68 (bool bDebug = true) in myplayercontroller.cpp

  9. Build it with DebugGame Editor, run the project in UE, Play and click to a white staticmesh box, breakpoint should be triggered: Indices is valid

  10. Cook in UE and then build it with DebugGame (standalone), run and click to same mesh: Indices is NULL

If you need further detail or sth not clear, pls let me know! :)

link text alt text

levelbp.png (91.1 kB)
avatar image Tim C ♦♦ STAFF Nov 11 '14 at 10:39 PM

Thank you for providing the additional reproduction steps. I was able to reproduce everything down through step 9. However, in step 10 when I try to run the project from Visual Studio in DebugGame configuration, it hits a breakpoint when loading, so I can't test for the crash that you were seeing.

I did see a different crash happening in DebugGame Editor if the Raytrace hit one of the walls of the level instead of first hitting a cube. It happens where HitStaticMeshComponent is created, so I don't think it is related to the original issue (Indices has not been created yet).

avatar image BigaCubensis Nov 11 '14 at 11:14 PM

Which breakpoint hit if you run without editor while loading? OK catching 10 would be important, my debuggame build ran correctly from VS and stops only at the BP I set. I assume cook done correctly there... I attach all sources generated/modified in my project, maybe there is a difference...

Yeah the other crash is irrelevant, it is due to short/demo code, it is only for staticmesh actors (which type we use in our game), other actors not handled. link text

raycasttestsrc.zip (119.9 kB)
avatar image Tim C ♦♦ STAFF Nov 12 '14 at 11:58 PM

The breakpoint issue I was experiencing turned out to be unrelated to the issue you were seeing. It was something that was recently fixed internally, and isn't something that should be a bother to you or other users.

After spending most of today trying to sort out the issue above, I was finally able to reproduce the issue that you described. I have a couple more tests I want to run tomorrow, and then I will be submitting a report to have this investigated further by one of our developers.

avatar image BigaCubensis Nov 13 '14 at 11:54 AM

thats a good news, thanks for your efforts.

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

2 answers: sort voted first

As BigaC mentions, we don't keep the index buffer CPU accessible outside the editor, to save memory. That is exactly what the bNeedsCPUAccess logic is doing. You should be able to change the logic though if you need access to the graphics triangles. Another option would be to ask the PhysX colliison mesh for the vertex (e.g. using PxMeshQuery::getTriangle).

more ▼

answered Nov 25 '14 at 12:12 PM

avatar image

JamesG STAFF
1.3k 8 8 32

avatar image PompeyPaul Nov 25 '14 at 02:49 PM

Thanks, won't the collision mesh and render mesh often be different? Thus I would need to modify the engine to keep the triangle list?

avatar image JamesG STAFF Nov 25 '14 at 03:33 PM

The per-poly collision should match the graphics triangles.

avatar image PompeyPaul Nov 25 '14 at 05:04 PM

Is that still true if the artist has supplied a separate collision mesh for the static mesh? Or is there always a per-poly collision mesh available? I.e. would going this route compel me to use per-poly collision meshes?

avatar image JamesG STAFF Nov 25 '14 at 05:21 PM

Artist supplied 'simple collision' is in addition to per-poly collision, you usually need both, and can choose which is used when you do the query. Hitscan weapons normally want to trace against actual visible geometry for example. The only time we don't pass the graphics polys to PhysX is if you disable collision for a section in the Static Mesh Editor.

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

Hi BigaC,

Sorry for not getting back to you yesterday. I have entered a ticket for this issue (UE-5494), and a developer will be investigating further.

Tim

more ▼

answered Nov 14 '14 at 09:38 PM

avatar image PompeyPaul Nov 19 '14 at 12:50 PM

I am being hit by exactly the same problem.

UDK: 4.5 Platform: Win

Crashes when it hits that line. How do I see the update on that ticket?

avatar image Tim C ♦♦ STAFF Nov 20 '14 at 07:19 PM

Hi PompeyPaul,

Unfortunately there isn't a way for you to directly check the ticket. However, if you ever need an update on the status of the ticket, please feel free to ask for one here. Any new posts here will re-open this issue, and we can check the ticket and give you an update.

Currently, the issue is still under investigation.

avatar image BigaCubensis Dec 21 '14 at 10:14 PM

Hello, anything news on the issue? Im asking because we tried an another approach, getting info from a texture of a screen 2d capturer, but that seems also failed:( so we would need the solution for this if possible...

thanks

avatar image Tim C ♦♦ STAFF Dec 29 '14 at 05:06 PM

Hi BigaC,

Sorry for the delayed response. If you refer to the answer posted by JamesG, the index buffer is not intended to be accessible outside of the Editor. That is what the bNeedsCPUAccess flag is checking for. It is intended primarily to help save memory, but you can certainly change the source code to allow it to be accessible outside of the Editor.

JamesG also mentioned another of querying the PhysX collision mesh.

Please let us know if you have any additional questions.

avatar image BigaCubensis Jan 04 '15 at 10:31 PM

I understand. The problem is we are coding a grand strategy game, not an FPS or RPG as majority of Unreal users. We would need somehow the exact color of the hit on a 3D map, because we identify the province/territory that way. We are slowly out of ideas how to realize a simple color query on the hit location with Unreal engine....

(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