Giter VIP home page Giter VIP logo

geometry_tools's People

Contributors

scanmountgoat avatar

Watchers

 avatar  avatar

geometry_tools's Issues

Improve bounding sphere calculations

The current implementation of bounding sphere calculation works fine for meshes that have all welded vertices, but in calculation of meshes that have unwelded vertices, duplicate vertex positions offsets the bounding sphere center, resulting in the radius to be larger than is optimal.

I am presenting a solution to this, which is simple in concept: remove duplicate vertex positions from the positions list. The following Python script performs both the current calculations and new calculations and prints the result of both. The center is usually closer to vanilla, and at times, the most optimal, which can result in a more optimal bounding sphere radius.

import ssbh_data_py
import numpy as np

mesh = ssbh_data_py.mesh_data.read_mesh("model.numshb")

for o in mesh.objects:
    positions_mean_old = [0, 0, 0]
    positions_mean_new = [0, 0, 0]

    print(f'Name: {o.name}, Index: {o.sub_index}')

    # Current geometry_tools calculation
    for [x, y, z] in o.positions[0].data:
        positions_mean_old += np.array([x, y, z])
    print(f'Old: {positions_mean_old / len(o.positions[0].data)}')

    # Offered geometry_tools calculation
    for [x, y, z] in np.unique(o.positions[0].data, axis=0):
        positions_mean_new += np.array([x, y, z])
    print(f'New: {positions_mean_new / len(np.unique(o.positions[0].data, axis=0))}\n')

This script only generates the center of the sphere, but I'd have to bet the radius is more optimal as a result.

Expose more functions through FFI

Add the main functions to FFI and add documentation for usage and safety. There should be specific functions for different types like vec3, vec3a, etc since generics won't work across the FFI boundary.

Improved smooth normals

This brings the features more in line with applications like Blender that allow users to customize the normals. The angle threshold is critical for hard surface modeling where an entirely welded mesh may still be expected to have sharp creases.

  • investigate weighting by face area
  • angle threshold (crease angle)
  • specify certain edges as hard edges

Support different index types

Applications will want to use any of the primitive unsigned integer types depending on the vertex format. Signed integers are unusual and probably aren't worth supporting.

mikktspace for tangents

Some users will want to use mikktspace for consistency between applications and game engines for normal maps. There isn't a safe Rust implementation at this time, and it doesn't make sense to develop and maintain one here. A possible solution is to link to another crate in the docs or wrap a crate with a similar API to the existing code in this repository.

Support Vec4

This is a common format for some game data and should give similar performance to Vec3A.

  • bounding spheres
  • normals
  • tangents

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.