Code Monkey home page Code Monkey logo

Comments (4)

JanDupal avatar JanDupal commented on May 3, 2024

From user's point of view I'd appreciate more solution 1.1. I find differentiating between general shapes and physics shapes bit confusing. Ideally user should be able to pass general shape and let framework decide (at compile time) whether it is related to debug drawing, collision detection, physics computation etc. depending on context. But I have no idea about implementation.

Could you please describe issue with ShapeGroup in 1.1?

from magnum.

JanDupal avatar JanDupal commented on May 3, 2024

Thoughts:

  1. Algebraic structure like Monoids for shapes
    • encapsulate single shape or shape group
    • provide % and composition operators
    • result: no specific (at least public) type to differentiate "primitive" from "composition of primitives"
    • issues: how to specify position of components in composition
  2. I like the idea with splitting Physics namespace
    • maybe Shapes and Physics
    • Where does "I'd like to render a box!" fit? Is it a primitive or a shape? What about "I'd like to render a box and make it collidable as fast as possible to see if my game idea works."?

from magnum.

mosra avatar mosra commented on May 3, 2024
  1. this is how it is currently - ShapeGroup which can contain one or more shapes, but the only advantage is the "universal" type, querying the contents is almost impossible. The shapes actually behave like monoids and you have to specify the type only during creation of single shapes, not for the result:
auto shape = Physics::Point2D({}) || Physics::Sphere2D({3.0f, 1.0f}, 0.5f);

Nice thing would be to have something like the following to avoid specifying the resulting type altogether to follow the monoids idea, maybe C++17 will be able to do it?:

new Shapes::Shape<auto>(object, shape);

Otherwise, to avoid explicit type specification, we must resort to some makeShape() function as described above.
2. Shapes and Physics, sure.

In current "terminology", primitive is mesh data (vertices, faces, normals...) of some basic object (circle, line, arrow, crosshair, monkey...) to ease up prototyping, shape is (simplified) description of some subspace (which doesn't even need to encapsulate any mesh, e.g. trigger volumes) used for collision detection (primarily not for rendering). User's line of thoughs should be like this:

  • I'd like to have a box object:
auto box = new Object3D(scene);
  • I'd like to have it collidable, thus I need to assign Shape feature to it and somehow describe its erm... shape, possibly using Shapes::Box3D:
auto shape = new Shapes::Shape<???>(box, Shapes::Box3D(...));
  • I'd like to visualize the box somehow. I have two options, assign Drawable feature to it and render a mesh (possibly created from pre-made Primitives::Cube) using some shader (possibly with stock Shaders::Phong). Or, because I have assigned the collision shape already, I can use DebugTools::ShapeRenderer, which will visualize just the shape with wireframe, it will look ugly, but I can do it better later:
new DebugTools::ShapeRenderer3D(shape, ...);

from magnum.

mosra avatar mosra commented on May 3, 2024

Done in 06d707f.

from magnum.

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.