Giter Site home page Giter Site logo

HeightField Collision shape about heron HOT 5 CLOSED

jcornaz avatar jcornaz commented on July 17, 2024
HeightField Collision shape

from heron.

Comments (5)

jcornaz avatar jcornaz commented on July 17, 2024 1

Hi, thanks @elegaanz!

Adding a new collision shape shouldn't be too hard. Add the new variant to Body (in core crate) and let the compiler tells you what else you need to change.

However.... I am currently making some big changes (see: #31 (comment)). So you might want to wait 2-3 days, to avoid unnecessary conflicts. (I plan to merge theses changes this weekend)

from heron.

jcornaz avatar jcornaz commented on July 17, 2024 1

Ah, and if you need help, you can either open a draft PR and/or contact me on discord (@jomag)

from heron.

jcornaz avatar jcornaz commented on July 17, 2024 1

I merged the changes I was talking about. So you can take the latest version of main and work from there.

Yes, you can use #[cfg(feature = ...)]. It looks like the best option in this case.

The Vec<Vec<f32>> is acceptable too. I'm don't know a nice dynamically sized matrix type that could replace this.

You'll also needs a scale member that tells the distance separating each height value of the vector/matrix.

In 2d it's a f32, and in 3d it's a Vec2. But, we may simplify it by forcing the user to use the same scale for both axis in 3d. This is anyway the most common, and as a matter of fact, I've never seen a height map with a different scale in x than in y. That means the scale could always be a f32 in both 2d and 3d.

enum CollisionShape {
    // ...

    #[cfg(not(all(feature = "2d", feature = "3d")))]
    HeightField {

        scale: f32,

        #[cfg(feature = "2d")]
        heigths: Vec<f32>,

        #[cfg(feature = "3d")]
        heigths: Vec<Vec<f32>>,
   }
}

P.S. The enum is now named "CollisionShape" ;-)

from heron.

elegaanz avatar elegaanz commented on July 17, 2024

Hi, I would like to help implement that, would a PR be accepted? (edit: I just saw the "up-for-grabs" label) If yes, do you have any tip or things I need to know about the code base or this issue before I get started?

from heron.

elegaanz avatar elegaanz commented on July 17, 2024

I started something, just to get a bit more familiar with the code, even if I need to redo it in a few days, and I have a question: in 2D heightfields are defined by a single-dimension array, but for 3D you need a matrix/two dimensional array. Is something like that a good idea?

enum Body {
    // ...
    HeightField {
        #[cfg(feature = "2d")]
        heigths: Vec<f32>,

        #[cfg(feature = "3d")]
        heigths: Vec<Vec<f32>>,
}

Or is there a better way?

from heron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.