scanmountgoat / geometry_tools Goto Github PK
View Code? Open in Web Editor NEWEfficient computation of single precision geometric data
License: MIT License
Efficient computation of single precision geometric data
License: MIT License
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.
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.
The initial implementation can just be naive solution guaranteed to contain all the specified spheres.
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.
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.
The current functions require creating an array or vector of glam::Vec3A, which likely isn't the format used for storage. This could be handled by adding conversion utilities and/or making the functions more generic.
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.
This is a common format for some game data and should give similar performance to Vec3A.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.