CesiumGS / cesium-unreal

Bringing the 3D geospatial ecosystem to Unreal Engine
https://cesium.com/platform/cesium-for-unreal/
Apache License 2.0
918 stars 293 forks source link

given model cannot be hit by UKismetSystemLibrary::LineTraceSingle #1038

Closed ycn2022 closed 1 year ago

ycn2022 commented 1 year ago

I have a model exported to 3dtiles, and loaded by CesiumForUnreal. but it cannot be hit use UKismetSystemLibrary::LineTraceSingle. the data file attached. tileset.zip

kring commented 1 year ago

I can reproduce this, but I'm not sure exactly what is happening. My best guess is that it's caused by degenerate triangles in that model. Line traces simply ignore it, but if we attempt to collide with it, Unreal (5.0 in my case) raises an assertion error:

LogChaos: Warning: Degenerate triangle 100: (2.004326 5.950058 3.330154) (2.052218 5.980874 3.355589) (2.010729 5.980874 3.323751)

ycn2022 commented 1 year ago

I wang to use FIntrRay3Triangle3d to check hit, can you give some suggest? thanks! this is the topic about this quesion: https://community.cesium.com/t/how-to-get-triangle-vertex-position-from-ucesiumgltfprimitivecomponent/22394

ycn2022 commented 1 year ago

I have created a pull request for this issue, at least can check collision by triangle.

https://github.com/CesiumGS/cesium-unreal/pull/1043

hanaimin commented 1 year ago

I can reproduce this, but I'm not sure exactly what is happening. My best guess is that it's caused by degenerate triangles in that model. Line traces simply ignore it, but if we attempt to collide with it, Unreal (5.0 in my case) raises an assertion error:

LogChaos: Warning: Degenerate triangle 100: (2.004326 5.950058 3.330154) (2.052218 5.980874 3.355589) (2.010729 5.980874 3.323751)

It seems that the cesium model uses the meter as the base unit and the value type is "double". Precision is lost in floating-point conversion, and for small triangles, it becomes a degenerate triangle. (It seems UE uses centimeters as the base unit)

kring commented 1 year ago

glTF meshes use 32-bit float precision vertices, just like Unreal meshes. And they're located in the world using 64-bit double precision matrixes, just like UE5 (but unlike UE4). It's true Cesium natively works in meters while UE works in centimeters, but this shouldn't have a significant impact on precision. Can you elaborate on what you're seeing?

ycn2022 commented 1 year ago

@hanaimin You are right, after coordinates multiplied by 100, it can be hit by UKismetSystemLibrary::LineTraceSingle. It seems to be caused by precision. Can Cesium solve this problem? @kring

engine5d commented 1 year ago

@hanaimin You are right, after coordinates multiplied by 100, it can be hit by UKismetSystemLibrary::LineTraceSingle. It seems to be caused by precision. Can Cesium solve this problem? @kring

@ycn2022 @kring if multiply 100, the original tile size will too large, and no conformable between cesiumjs and cesium-unreal. I considered it's best to keep the real size of mesh.

kring commented 1 year ago

It's not obvious to me what we can do to solve this one. If the triangles that Unreal is reporting as degenerate are actually useful, this needs to be reported as a bug to Epic. But let me know if you have an idea that I've missed.

kring commented 1 year ago

We've had some work in this area recently that hopefully ended up solving this problem:

I'm closing this because I don't think it's actionable. But if you're still having problems in v1.28+, please write a separate issue with as much information as possible.