Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose HeightfieldColliderShape to use it in Game Studio #561

Merged

Conversation

EternalTamago
Copy link
Contributor

@EternalTamago EternalTamago commented Nov 28, 2019

Updated 2020/03/31

PR Details

Expose HeightfieldColliderShape to use it in Game Studio.

scene_heightfield

  • Add HeightmapAsset used to set initial heights of heightfield.
  • Add HeightfieldColliderShapeDesc to expose HeightfieldColliderShape in Game Studio.
  • Add AlwaysUpdateNaviMeshCache property to StaticColliderComponent to update the cache at rebuilding navigation mesh.

Description

HeightmapAsset

Used to initialize heights of heightfield.

add_heightmap

heightmap_asset_thumbnail

heightmap_asset_property

Source

An image file used to generate heightmap from its R channels.

Floating Point Component Range

Determine the range of the floating-point component when the R component is the floating point component.

Is Symmetric Short Component

Determine the range of the signed short integer component when the R component is the signed short integer component.
If enabled, [-32767 .. 32767], otherwise [-32768 .. 32767].

s RGB sampling

Enable if needed to load the image file as sRGB.

Height

Type of height.

Height Range

X is min height and Y is max height. "height * HeightScale" should be in this range. In Byte height type, the range can't include both of positive and negative.

Height Scale

In Short type or in Byte type, "height * HeightScale" is used for collisions in physics. In Float type, heights are used as they are.

item description
Auto HeightScale Calculated from HeightRange
Custom Custom HeightScale

Resize

New size of the heightmap. X is width and Y is length. If disabled, the size is same to the image size(width * height). Width and length should be greater than or equal to 2.

Scale To Height Range

If enabled, scale each of the heights to the height range before they are stored as heightmap. By the default, they are considered to be in [-1 .. 1] when the R component is floating-point component format. Edit FloatingPointComponentRange to actual floating point component range(e.g. [0 .. 1]), if needed.

HeightfieldColliderShapeDesc

Used to create HeightfieldColliderShape.

heightfield_inline_property

Source

The source to initialize heights.

Heightmap

The heightmap to initialize heights.

Float, Short and Byte

Type of height.

Size

Size of the heightfield. X is width and Y is length. Width and length should be greater than or equal to 2. The Size should be 65 * 65 when you want 64 * 64 size in a scene.

Height Range

X is min height and Y is max height. "height * HeightScale" should be in this range. In Byte height type, the range can't include both of positive and negative.

Height Scale

In Short type or in Byte type, "height * HeightScale" is used for collisions in physics. In Float type, heights are used as they are.

item description
Auto HeightScale Calculated from HeightRange
Custom Custom HeightScale

Flip Quad Edges

Change how triangles forming heightfield collider shape are generated.(I'm not sure about this)

Centering

Add offset to ColliderShape.LocalOffset in order to center specific height.

StaticColliderComponent.AlwaysUpdateNaviMeshCache

Enable if you want to update the cache of the collider shape at rebuilding the NavigationMesh.

Use one of the following arrays to update the heights at runtime.

HeightType Heights of heightfield
Float HeightfieldColliderShape.FloatArray
Short HeightfieldColliderShape.ShortArray
Byte HeightfieldColliderShape.ByteArray

Related Issue

#494

Motivation and Context

Currently there is HeightfieldColliderShape but it can be created only at runtime. It's not available in Game Studio and NavigationMesh.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@EternalTamago EternalTamago marked this pull request as ready for review November 28, 2019 19:44
@HeadClot
Copy link

HeadClot commented Dec 1, 2019

I love this PR.

@HeadClot HeadClot mentioned this pull request Dec 1, 2019
Copy link
Member

@xen2 xen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, great PR!
Kudo for the good code, and extra effort to add previews/thumbnails!

Looks good to me. Added a few comments but it's mostly small details.

sources/engine/Xenko.Physics/Engine/Heightmap.cs Outdated Show resolved Hide resolved
@xen2
Copy link
Member

xen2 commented Dec 4, 2019

Tried with a heightmap but couldn't get it to work properly (doesn't match the heightmap that you can see in the asset browser):

image

I tried float/short/byte (set to same value on both component collider shape's list and heightmap asset).
Anything I might have forget?

Also small remark, maybe HeightmapAsset.Size might be better to default to something meaningful like 1024 rather than 0? (even if not enabled)

@EternalTamago
Copy link
Contributor Author

It seems that Heightmap size is not same to HeightStickSize.
Does that happen even if those are matched? (Enable Resize of HeightmapAsset and set it to 80x80)
Heightfield uses heightmap as it is, that doesn't try to match the size.

HeightmapAsset.Size

Yes, I think so too.
It might be better that that is same to default value of HeightStickSize?

@EternalTamago
Copy link
Contributor Author

Would it better to change the list of the property to this?

another_property_type

BTW, I realized that HeightfieldColliderShape.FloatArray/ShortArray/ByteArray should be locked while building the navigation mesh.

@xen2
Copy link
Member

xen2 commented Mar 29, 2020

@EternalTamago Hey, in few days Xenko will be renamed to Stride so it's easier to merge PRs before that. Let me know if you have a working version that can be merged already.
Otherwise no worries, I will guide you on how to make sure PR don't conflict with the renaming whenever you are ready.

…o update the cache at rebuilding NavigationMesh.

GetStaticColliderCacheSettings and things related to it are no longer used.
… be suitable them.

IHeightfieldHeightDescription --> IHeightStickParameters.
IInitialHeightfieldHeightData --> IHeightStickArraySource.
HeightfieldHeightDataFromHeightmap --> HeightStickArraySourceFromHeightmap.
EmptyFloatHeightfieldHeightData --> FloatHeightStickArraySource.
EmptyShortHeightfieldHeightData --> ShortHeightStickArraySource.
EmptyByteHeightfieldHeightData --> ByteHeightStickArraySource.
IHeightfieldHeightScaleCalculator --> IHeightScaleCalculator.
HeightfieldHeightScaleCalculator --> HeightScaleCalculator.
HeightfieldHeightScaleCalculatorWithValue --> PrecalculatedHeightScaleCalculator.
@EternalTamago
Copy link
Contributor Author

EternalTamago commented Mar 30, 2020

@xen2 Yes. Sorry for the late reply!

@EternalTamago EternalTamago changed the title [WIP] Expose HeightfieldColliderShape to use it in Game Studio Expose HeightfieldColliderShape to use it in Game Studio Mar 30, 2020
@xen2 xen2 self-assigned this Apr 4, 2020
@EternalTamago
Copy link
Contributor Author

@xen2 The current state is everything. My words were not enough. Sorry if you are blocked by me.

@xen2
Copy link
Member

xen2 commented Apr 10, 2020

@EternalTamago
Thanks for clarification! No worries, I understood it was complete with previous messages.
I wanted to test it quickly before merging, sorry for the delay.

@xen2 xen2 merged commit 646e67c into stride3d:master Apr 11, 2020
@EternalTamago EternalTamago deleted the feature_3.1_heightfield_in_game_studio branch April 23, 2020 15:33
@Aggror
Copy link
Member

Aggror commented May 11, 2020

@EternalTamago Hi EternalTamago,
You wouldn't happen to have a nice video recording that demonstrates the heightmap field with a nice example scene? I want to compile a nice video containing the cool new features for the Stride 4.0 release.
If you have anything resource wise that can help out with showcasing your heightfielf PR, you can contact me on Discord #Aggror#6358 or here on Gitbhub.

@EternalTamago
Copy link
Contributor Author

Hi, @Aggror
I'll try to record simple video with Stride sample assets etc in a few days.
(You don't have to wait for it when we don't have the time.)

@Aggror
Copy link
Member

Aggror commented May 15, 2020

Note that we will now just use small videos in the release notes instead of one long video.

@EternalTamago
Copy link
Contributor Author

@Aggror
I have sent the video to you via DM in Discord.

@Kryptos-FR
New video may be same as the above mostly except that bitrate 😄

@EternalTamago
Copy link
Contributor Author

@xen2
Recently I posted separately #734 from #494.
And I'd like to know what you think about #734 and the heightfield.
That is related to the stability of Stride.

For me, the heightfield collider shape in Game Studio is useful even if there is that issue.
However, the issue might be critical for some users that try to use the heightfield.
What do you think about this?

I know that it's too late to talk, but I think that we should get clarity on this before the release.
I'm sorry to bother you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants