// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 #pragma once #include "geometry_meshing_parameters_interface.hpp" #include #include #include #include frantic::particles::particle_istream_ptr prepare_radius_channel( frantic::particles::particle_istream_ptr pin, float radius, bool overwrite ); frantic::particles::particle_istream_ptr prepare_color_channel( frantic::particles::particle_istream_ptr pin ); void conform_mesh_channel_types( frantic::geometry::trimesh3& mesh, const frantic::channels::channel_map& vertexChannelMap, std::size_t skipChannelIndex, const frantic::channels::channel_map& faceChannelMap ); void get_channel_accessors( frantic::geometry::trimesh3& mesh, const frantic::channels::channel_map& vertexChannelMap, const frantic::channels::channel_map& faceChannelMap, std::vector& outVertexAccessors, std::vector& outFaceAccessors ); void build_plane_mesh( frantic::geometry::trimesh3& outMesh, const frantic::channels::channel_map& vertexChannelMap, const frantic::channels::channel_map& faceChannelMap, frost::hard_edge_type::option hardEdgeType ); void build_sprite_mesh( frantic::geometry::trimesh3& outMesh, const frantic::channels::channel_map& vertexChannelMap, const frantic::channels::channel_map& faceChannelMap, frost::hard_edge_type::option hardEdgeType ); void build_tetrahedron_mesh( frantic::geometry::trimesh3& outMesh, const frantic::channels::channel_map& vertexChannelMap, const frantic::channels::channel_map& faceChannelMap, frost::hard_edge_type::option hardEdgeType ); // void build_pyramid_mesh( frantic::geometry::trimesh3 & outMesh, const std::vector & channelNames, const // std::vector & inputChannels ); void build_box_mesh( frantic::geometry::trimesh3& outMesh, const frantic::channels::channel_map& vertexChannelMap, const frantic::channels::channel_map& faceChannelMap, frost::hard_edge_type::option hardEdgeType ); void build_sphere_mesh( frantic::geometry::trimesh3& outMesh, const frantic::channels::channel_map& vertexChannelMap, const frantic::channels::channel_map& faceChannelMap, frost::hard_edge_type::option hardEdgeType ); boost::shared_ptr randomize_radius_by_id( const boost::shared_ptr inParticles, const frantic::tstring& idChannel, const frantic::tstring& radiusChannel, const float variation, const int seed ); inline float get_unit_random_from_id( boost::int32_t id, boost::uint32_t randomSeed ) { boost::uint32_t hash = hashword( reinterpret_cast( &id ), 1, randomSeed ); return static_cast( hash ) / static_cast( std::numeric_limits::max() ); } inline boost::int32_t id_randomized_geometry( boost::int32_t id, boost::int32_t elements, boost::int32_t randomSeed ) { boost::uint32_t hashedID = hashword( reinterpret_cast( &id ), 1, randomSeed ); float unitRandom = static_cast( hashedID ) / static_cast( std::numeric_limits::max() ); return int( elements * ( 1.f - unitRandom ) ); } inline float id_randomized_rotation( boost::int32_t id, float maxRotation, boost::int32_t randomSeed = 12345 ) { boost::uint32_t hashedID = hashword( reinterpret_cast( &id ), 1, randomSeed ); float unitRandom = static_cast( hashedID ) / static_cast( std::numeric_limits::max() ); return maxRotation * ( 1.f - unitRandom ); } inline float id_randomized_radius( boost::int32_t id, float radius, float variation, boost::uint32_t randomSeed ) { boost::uint32_t hashedID = hashword( reinterpret_cast( &id ), 1, randomSeed ); float unitRandom = static_cast( hashedID ) / static_cast( std::numeric_limits::max() ); // Only shrink the particles, because we are using the original radius as the basis for acceleration grids return radius * ( 1.f - unitRandom * variation ); } template T mod_trunc_neginf( T a, T b ) { int result = a % b; if( result < 0 ) { result += b; } return result; }