- Timestamp:
- 07/08/15 17:33:38 (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv.lua
r396 r410 147 147 148 148 configuration "vs*" 149 defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1" , "_ITERATOR_DEBUG_LEVEL=0", "_HAS_ITERATOR_DEBUGGING=0" }149 defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1" } --, "_ITERATOR_DEBUG_LEVEL=0", "_HAS_ITERATOR_DEBUGGING=0" } 150 150 151 151 if _ACTION == "gmake-clang" then -
trunk/nv/core/arcball.hh
r398 r410 65 65 p.z = sqrt( 1.0f - sq ); 66 66 else 67 p = math::normalize( p );67 p = glm::normalize( p ); 68 68 return p; 69 69 } -
trunk/nv/formats/nmd_loader.hh
r395 r410 55 55 }; 56 56 57 struct nmd_key_channel_header58 {59 key_descriptor format;60 uint32 count;61 };62 63 57 struct nmd_stream_header 64 58 { 65 vertex_descriptor format;66 uint32 count;59 data_descriptor format; 60 uint32 count; 67 61 }; 68 62 -
trunk/nv/formats/obj_loader.hh
r395 r410 32 32 ~obj_loader(); 33 33 private: 34 vertex_descriptorm_descriptor;34 data_descriptor m_descriptor; 35 35 bool m_normals; 36 36 bool m_tangents; -
trunk/nv/gfx/animation.hh
r406 r410 12 12 #include <nv/interface/stream.hh> 13 13 #include <nv/stl/math.hh> 14 #include <nv/interface/ animation_key.hh>14 #include <nv/interface/data_descriptor.hh> 15 15 #include <nv/interface/interpolation_raw.hh> 16 16 #include <nv/interface/interpolation_template.hh> … … 22 22 struct key_raw_channel 23 23 { 24 key_descriptor desc;25 uint8* data;26 uint32 count;24 data_descriptor desc; 25 uint8* data; 26 uint32 count; 27 27 28 28 key_raw_channel() : data( nullptr ), count( 0 ) {} … … 32 32 } 33 33 34 uint32 size() const { return count * desc. size; }34 uint32 size() const { return count * desc.element_size(); } 35 35 36 36 template < typename KEY > … … 44 44 } 45 45 46 static key_raw_channel* create( const key_descriptor& keydesc, uint32 count = 0 )46 static key_raw_channel* create( const data_descriptor& keydesc, uint32 count = 0 ) 47 47 { 48 48 key_raw_channel* result = new key_raw_channel(); … … 56 56 { 57 57 if ( count == 0 ) return 0; 58 uint32 keyfsize = desc. size/ 4;58 uint32 keyfsize = desc.element_size() / 4; 59 59 const float* fdata = reinterpret_cast<const float*>( data ) + keyfsize * index; 60 60 uint32 mod = 0; 61 if ( desc .slots[0].vslot == animation_slot::TIME ) mod = 1;61 if ( desc[0].vslot == slot::TIME ) mod = 1; 62 62 raw_copy_n( fdata + mod, keyfsize - mod, result ); 63 63 return keyfsize - mod; … … 67 67 { 68 68 if ( count == 0 ) return 0; 69 uint32 keyfsize = desc. size/ 4;69 uint32 keyfsize = desc.element_size() / 4; 70 70 uint32 keyfresult = keyfsize; 71 71 const float* fdata = reinterpret_cast<const float*>( data ); … … 75 75 int index1 = -1; 76 76 float factor = 1.0f; 77 if ( desc .slots[0].vslot == animation_slot::TIME )78 { 79 NV_ASSERT( desc .slots[0].offset == 0, "time offset not zero!" );77 if ( desc[0].vslot == slot::TIME ) 78 { 79 NV_ASSERT( desc[0].offset == 0, "time offset not zero!" ); 80 80 slot++; 81 81 keyfresult--; … … 112 112 } 113 113 uint32 ret = 0; 114 for ( ; slot < desc. count; ++slot )114 for ( ; slot < desc.slot_count(); ++slot ) 115 115 { 116 116 ret += nv::interpolate_raw( 117 desc .slots[slot], factor,118 fdata + index0 * static_cast<int>( keyfsize ) + desc .slots[slot].offset / 4,119 fdata + index1 * static_cast<int>( keyfsize ) + desc .slots[slot].offset / 4,117 desc[slot], factor, 118 fdata + index0 * static_cast<int>( keyfsize ) + desc[slot].offset / 4, 119 fdata + index1 * static_cast<int>( keyfsize ) + desc[slot].offset / 4, 120 120 result + ret ); 121 121 } … … 133 133 NV_ASSERT( channel, "nullptr passed to add_channel!" ); 134 134 m_channels.push_back( channel ); 135 for ( uint16 i = 0; i < channel->desc.count; ++i ) 136 { 137 const key_descriptor_slot& ksi = channel->desc.slots[i]; 138 if ( ksi.vslot != animation_slot::TIME ) 139 { 140 uint32 index = m_final_key.count; 141 m_final_key.slots[ index ].offset = m_final_key.size; 142 m_final_key.slots[ index ].etype = ksi.etype; 143 m_final_key.slots[ index ].vslot = ksi.vslot; 144 m_final_key.size += get_datatype_info( ksi.etype ).size; 145 m_final_key.count++; 146 } 147 } 135 for ( const auto& cslot : channel->desc ) 136 if ( cslot.vslot != slot::TIME ) 137 m_final_key.push_slot( cslot.etype, cslot.vslot ); 148 138 } 149 139 … … 194 184 size_t get_channel_count() const { return m_channels.size(); } 195 185 const key_raw_channel* get_channel( size_t index ) const { return m_channels[ index ]; } 196 const key_descriptor& get_final_key() const { return m_final_key; }186 const data_descriptor& get_final_key() const { return m_final_key; } 197 187 198 188 virtual ~key_data() … … 201 191 } 202 192 private: 203 key_descriptor m_final_key;193 data_descriptor m_final_key; 204 194 vector< key_raw_channel* > m_channels; 205 195 }; … … 219 209 { 220 210 m_data = data; 221 key_descriptor desc;211 data_descriptor desc; 222 212 desc.initialize<KEY>(); 223 213 NV_ASSERT( data->desc == desc, "Bad channel passed!" ); … … 251 241 { 252 242 m_data = data; 253 key_descriptor desc;243 data_descriptor desc; 254 244 desc.initialize<KEY>(); 255 245 NV_ASSERT( data->desc == desc, "Bad channel passed!" ); … … 366 356 explicit transform_vector( const key_raw_channel* channel ) 367 357 { 368 key_descriptor kd;358 data_descriptor kd; 369 359 kd.initialize<key>(); 370 360 NV_ASSERT( kd == channel->desc, "bad channel!" ); -
trunk/nv/gfx/skeletal_mesh.hh
r395 r410 106 106 virtual transform get_node_transform( uint32 node_id ) const; 107 107 virtual mat4 get_node_matrix( uint32 node_id ) const; 108 ~skeletal_mesh_gpu() { delete m_transform; }108 ~skeletal_mesh_gpu() { delete[] m_transform; } 109 109 protected: 110 110 const mesh_nodes_data* m_bone_data; -
trunk/nv/interface/context.hh
r406 r410 132 132 void add_vertex_buffer_impl( vertex_array va, buffer vb, const true_type& ) 133 133 { 134 typedef vertex_slot_info< VTX, SLOT > vinfo;134 typedef slot_info< VTX, SLOT > vinfo; 135 135 typedef datatype_traits< typename vinfo::value_type > dt_traits; 136 136 add_vertex_buffer( va, SLOT, vb, type_to_enum< typename dt_traits::base_type >::type, dt_traits::size, vinfo::offset, sizeof( VTX ), false ); … … 140 140 void add_vertex_buffer( vertex_array va, buffer vb ) 141 141 { 142 add_vertex_buffer_impl< VTX, SLOT >( va, vb, bool_constant< vertex_has_slot< VTX, SLOT >::value>() );142 add_vertex_buffer_impl< VTX, SLOT >( va, vb, has_slot< VTX, SLOT >() ); 143 143 } 144 144 … … 157 157 void add_vertex_buffers( vertex_array va, buffer buf, const mesh_raw_channel* channel ) 158 158 { 159 for ( uint32 s = 0; s < channel->desc.count; ++s)160 { 161 const vertex_descriptor_slot& slot = channel->desc.slots[s];162 const datatype_info& info = get_datatype_info(slot.etype);163 add_vertex_buffer( va, slot.vslot, buf, info.base , info.elements, slot.offset, channel->desc.size, false );164 165 } 159 for ( const auto& cslot : channel->desc ) 160 { 161 const datatype_info& info = get_datatype_info( cslot.etype ); 162 add_vertex_buffer( va, cslot.vslot, buf, info.base, info.elements, cslot.offset, channel->desc.element_size(), false ); 163 } 164 } 165 166 166 167 167 template < typename VTXDATA > … … 311 311 if ( type == INDEX_BUFFER ) 312 312 { 313 set_index_buffer( va, b, channel->desc .slots[0].etype, true );313 set_index_buffer( va, b, channel->desc[0].etype, true ); 314 314 } 315 315 else -
trunk/nv/interface/device.hh
r406 r410 113 113 : filter_min( f ), filter_max( f ), wrap_s( w ), wrap_t( w ) {} 114 114 115 }; 116 117 enum buffer_hint 118 { 119 STATIC_DRAW, 120 STREAM_DRAW, 121 DYNAMIC_DRAW 115 122 }; 116 123 -
trunk/nv/interface/interpolation_raw.hh
r406 r410 13 13 #include <nv/core/transform.hh> 14 14 #include <nv/stl/math.hh> 15 #include <nv/interface/ animation_key.hh>15 #include <nv/interface/data_descriptor.hh> 16 16 17 17 namespace nv … … 33 33 } 34 34 35 inline uint32 interpolate_raw( const key_descriptor_slot& slot, float factor, const float* k1, const float* k2, float* result )35 inline uint32 interpolate_raw( const data_descriptor_slot& slot, float factor, const float* k1, const float* k2, float* result ) 36 36 { 37 37 uint32 count = get_datatype_info( slot.etype ).elements; 38 38 switch ( slot.vslot ) 39 39 { 40 case animation_slot::TIME:return 0;41 case animation_slot::POSITION: return interpolate_raw_linear( count, factor, k1, k2, result );42 case animation_slot::ROTATION:return interpolate_raw_quat( factor, k1, k2, result );43 case animation_slot::SCALE:return interpolate_raw_linear( count, factor, k1, k2, result );44 case animation_slot::TFORM:return40 case slot::TIME: return 0; 41 case slot::TRANSLATION: return interpolate_raw_linear( count, factor, k1, k2, result ); 42 case slot::ROTATION: return interpolate_raw_quat( factor, k1, k2, result ); 43 case slot::SCALE: return interpolate_raw_linear( count, factor, k1, k2, result ); 44 case slot::TFORM: return 45 45 interpolate_raw_linear( 3, factor, k1, k2, result ) + 46 46 interpolate_raw_quat( factor, k1 + 3, k2 + 3, result + 3 ); … … 57 57 } 58 58 59 inline mat4 extract_matrix_raw( const key_descriptor& desc, const float* data )59 inline mat4 extract_matrix_raw( const data_descriptor& desc, const float* data ) 60 60 { 61 if ( desc. count== 1 )61 if ( desc.slot_count() == 1 ) 62 62 { 63 switch ( desc .slots[0].vslot )63 switch ( desc[0].vslot ) 64 64 { 65 case animation_slot::TIME:return mat4();66 case animation_slot::POSITION: return glm::translate( mat4(), make_vec3( data ) );67 case animation_slot::ROTATION:return mat4_cast( make_quat_fixed( data ) );68 case animation_slot::SCALE:return glm::scale( mat4(),make_vec3( data ) );69 case animation_slot::TFORM:return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ).extract();65 case slot::TIME: return mat4(); 66 case slot::TRANSLATION: return glm::translate( mat4(), make_vec3( data ) ); 67 case slot::ROTATION: return mat4_cast( make_quat_fixed( data ) ); 68 case slot::SCALE: return glm::scale( mat4(),make_vec3( data ) ); 69 case slot::TFORM: return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ).extract(); 70 70 default: 71 71 return mat4(); … … 74 74 else 75 75 { 76 mat4 position;76 mat4 translation; 77 77 mat4 rotation; 78 78 mat4 scale; 79 for ( uint32 i = 0; i < desc.count; ++i)79 for ( auto& slot : desc ) 80 80 { 81 uint32 offset = desc.slots[i].offset / 4;82 switch ( desc.slots[i].vslot )81 uint32 offset = slot.offset / 4; 82 switch ( slot.vslot ) 83 83 { 84 case animation_slot::TIME: break;85 case animation_slot::POSITION:86 position = glm::translate( position,make_vec3( data + offset ) ); break;87 case animation_slot::ROTATION:84 case slot::TIME: break; 85 case slot::TRANSLATION: 86 translation = glm::translate( translation,make_vec3( data + offset ) ); break; 87 case slot::ROTATION: 88 88 rotation = mat4_cast( make_quat_fixed( data + offset ) ); break; 89 case animation_slot::SCALE:89 case slot::SCALE: 90 90 scale = glm::scale( mat4(),make_vec3( data + offset ) ); break; 91 case animation_slot::TFORM: return transform( make_vec3( data + offset ), make_quat_fixed( data + offset + 3 ) ).extract();91 case slot::TFORM: return transform( make_vec3( data + offset ), make_quat_fixed( data + offset + 3 ) ).extract(); 92 92 default: 93 93 break; 94 94 } 95 95 } 96 return position * rotation * scale;96 return translation * rotation * scale; 97 97 } 98 98 } 99 99 100 inline transform extract_transform_raw( const key_descriptor& desc, const float* data )100 inline transform extract_transform_raw( const data_descriptor& desc, const float* data ) 101 101 { 102 if ( desc. count== 1 )102 if ( desc.slot_count() == 1 ) 103 103 { 104 switch ( desc .slots[0].vslot )104 switch ( desc[0].vslot ) 105 105 { 106 case animation_slot::TIME:return transform();107 case animation_slot::POSITION: return transform( make_vec3( data ) );108 case animation_slot::ROTATION:return transform( make_quat_fixed( data ) );109 case animation_slot::SCALE:return transform();110 case animation_slot::TFORM:return transform( make_vec3( data ), make_quat_fixed( data + 3 ) );106 case slot::TIME: return transform(); 107 case slot::TRANSLATION: return transform( make_vec3( data ) ); 108 case slot::ROTATION: return transform( make_quat_fixed( data ) ); 109 case slot::SCALE: return transform(); 110 case slot::TFORM: return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ); 111 111 default: 112 112 return transform(); … … 115 115 else 116 116 { 117 vec3 position;117 vec3 translation; 118 118 quat rotation; 119 for ( uint32 i = 0; i < desc.count; ++i)119 for ( auto& slot : desc ) 120 120 { 121 uint32 offset = desc.slots[i].offset / 4;122 switch ( desc.slots[i].vslot )121 uint32 offset = slot.offset / 4; 122 switch ( slot.vslot ) 123 123 { 124 case animation_slot::TIME: break;125 case animation_slot::POSITION:126 position = make_vec3( data + offset ); break;127 case animation_slot::ROTATION:124 case slot::TIME: break; 125 case slot::TRANSLATION: 126 translation = make_vec3( data + offset ); break; 127 case slot::ROTATION: 128 128 rotation = make_quat_fixed( data + offset ); break; 129 case animation_slot::SCALE: break;130 case animation_slot::TFORM: return transform( make_vec3( data + offset ), make_quat_fixed( data + 3 ) );129 case slot::SCALE: break; 130 case slot::TFORM: return transform( make_vec3( data + offset ), make_quat_fixed( data + 3 ) ); 131 131 default: 132 132 break; 133 133 } 134 134 } 135 return transform( position, rotation );135 return transform( translation, rotation ); 136 136 } 137 137 } 138 138 139 inline void transform_key_ position( uint8* data, float scale, const mat3& r33 )139 inline void transform_key_translation( uint8* data, float scale, const mat3& r33 ) 140 140 { 141 141 vec3& p = *( reinterpret_cast<vec3*>( data ) ); … … 161 161 } 162 162 163 inline void transform_key_raw( const key_descriptor& desc, uint8* data, float scale, const mat3& r33, const mat3& ri33 )163 inline void transform_key_raw( const data_descriptor& desc, uint8* data, float scale, const mat3& r33, const mat3& ri33 ) 164 164 { 165 for ( uint32 i = 0; i < desc.count; ++i)165 for ( auto& slot : desc ) 166 166 { 167 uint32 offset = desc.slots[i].offset;168 switch ( desc.slots[i].vslot )167 uint32 offset = slot.offset / 4; 168 switch ( slot.vslot ) 169 169 { 170 case animation_slot::TIME: break;171 case animation_slot::POSITION: transform_key_position( data + offset, scale, r33 ); break;172 case animation_slot::ROTATION:transform_key_rotation( data + offset, r33, ri33 ); break;173 case animation_slot::SCALE:transform_key_scale( data + offset, scale ); break;174 case animation_slot::TFORM:transform_key_transform( data + offset, scale, r33, ri33 ); break;170 case slot::TIME: break; 171 case slot::TRANSLATION: transform_key_translation( data + offset, scale, r33 ); break; 172 case slot::ROTATION: transform_key_rotation( data + offset, r33, ri33 ); break; 173 case slot::SCALE: transform_key_scale( data + offset, scale ); break; 174 case slot::TFORM: transform_key_transform( data + offset, scale, r33, ri33 ); break; 175 175 default: 176 176 break; -
trunk/nv/interface/interpolation_template.hh
r395 r410 13 13 #include <nv/core/transform.hh> 14 14 #include <nv/stl/math.hh> 15 #include <nv/interface/ animation_key.hh>15 #include <nv/interface/data_descriptor.hh> 16 16 17 17 namespace nv 18 18 { 19 19 20 template < typename KEY, animation_slot SLOT > 21 void interpolate_slot( KEY& key, const KEY& k1, const KEY& k2, float factor, const true_type& ) 22 { 23 key_slot_info< KEY, SLOT >::interpolate( key, k1, k2, factor ); 24 } 25 26 template < typename KEY, animation_slot SLOT > 27 void interpolate_slot( KEY&, const KEY&, const KEY&, float, const false_type& ) 28 { 29 } 20 template < typename Key, slot Slot, bool HasKey = has_slot< Key, Slot >::value > 21 struct slot_interpolator; 22 23 template < typename Key, slot Slot > 24 struct slot_interpolator< Key, Slot, false > 25 { 26 static void interpolate( Key&, const Key&, const Key&, float ) 27 { 28 } 29 }; 30 31 template < typename Key > 32 struct slot_interpolator< Key, slot::TRANSLATION, true > 33 { 34 static void interpolate( Key& key, const Key& k1, const Key& k2, float factor ) 35 { 36 key.translation = ::nv::interpolate( k1.translation, k2.translation, factor ); 37 } 38 }; 39 40 template < typename Key > 41 struct slot_interpolator< Key, slot::ROTATION, true > 42 { 43 static void interpolate( Key& key, const Key& k1, const Key& k2, float factor ) 44 { 45 key.rotation = nv::interpolate( k1.rotation, k2.rotation, factor ); 46 } 47 }; 48 49 template < typename Key > 50 struct slot_interpolator< Key, slot::SCALE, true > 51 { 52 static void interpolate( Key& key, const Key& k1, const Key& k2, float factor ) 53 { 54 key.scale = nv::interpolate( k1.scale, k2.scale, factor ); 55 } 56 }; 57 58 template < typename Key > 59 struct slot_interpolator< Key, slot::TFORM, true > 60 { 61 static void interpolate( Key& key, const Key& k1, const Key& k2, float factor ) 62 { 63 key.tform = nv::interpolate( k1.tform, k2.tform, factor ); 64 } 65 }; 30 66 31 67 template < typename KEY > 32 68 void interpolate_key( KEY& key, const KEY& k1, const KEY& k2, float factor ) 33 69 { 34 interpolate_slot< KEY, animation_slot::POSITION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::POSITION >());35 interpolate_slot< KEY, animation_slot::ROTATION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::ROTATION >());36 interpolate_slot< KEY, animation_slot::SCALE >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::SCALE >());37 interpolate_slot< KEY, animation_slot::TFORM >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::TFORM >());70 slot_interpolator< KEY, slot::TRANSLATION >::interpolate( key, k1, k2, factor ); 71 slot_interpolator< KEY, slot::ROTATION >::interpolate( key, k1, k2, factor ); 72 slot_interpolator< KEY, slot::SCALE >::interpolate( key, k1, k2, factor ); 73 slot_interpolator< KEY, slot::TFORM >::interpolate( key, k1, k2, factor ); 38 74 } 39 75 … … 51 87 52 88 template < typename KEY > 53 mat4 extract_matrix_p_impl( const KEY& k ) { return glm::translate(mat4(),k. position); }89 mat4 extract_matrix_p_impl( const KEY& k ) { return glm::translate(mat4(),k.translation); } 54 90 template < typename KEY > 55 91 mat4 extract_matrix_r_impl( const KEY& k ) { return glm::mat4_cast( k.rotation ); } … … 61 97 // TODO: this is obviously unoptimized 62 98 mat4 result = glm::mat4_cast( k.rotation ); 63 result[3] = vec4( k. position, 1.0f );99 result[3] = vec4( k.translation, 1.0f ); 64 100 return result; 65 101 } … … 75 111 { 76 112 // TODO: this is obviously unoptimized 77 return glm::scale(glm::translate(mat4(),k. position),k.scale);113 return glm::scale(glm::translate(mat4(),k.translation),k.scale); 78 114 } 79 115 template < typename KEY > … … 81 117 { 82 118 // TODO: this is obviously unoptimized 83 return glm::translate(mat4(),k. position) * glm::mat4_cast( k.rotation ) * glm::scale(mat4(),k.scale);119 return glm::translate(mat4(),k.translation) * glm::mat4_cast( k.rotation ) * glm::scale(mat4(),k.scale); 84 120 } 85 121 … … 113 149 transform extract_transform_pr_impl( const KEY&, const false_type&, const false_type& ) { return transform(); } 114 150 template < typename KEY > 115 transform extract_transform_pr_impl( const KEY& k, const true_type&, const true_type& ) { return transform( k. position, k.rotation ); }116 template < typename KEY > 117 transform extract_transform_pr_impl( const KEY& k, const true_type&, const false_type& ) { return transform( k. position ); }151 transform extract_transform_pr_impl( const KEY& k, const true_type&, const true_type& ) { return transform( k.translation, k.rotation ); } 152 template < typename KEY > 153 transform extract_transform_pr_impl( const KEY& k, const true_type&, const false_type& ) { return transform( k.translation ); } 118 154 template < typename KEY > 119 155 transform extract_transform_pr_impl( const KEY& k, const false_type&, const true_type& ) { return transform( k.rotation ); } … … 124 160 mat4 extract_matrix_impl( const KEY& k, const true_type& ) 125 161 { 126 static_assert( key_has_slot< KEY, animation_slot::POSITION >::value == false, "key!");127 static_assert( key_has_slot< KEY, animation_slot::ROTATION >::value == false, "key!");128 static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!");162 static_assert( has_slot< KEY, slot::TRANSLATION >::value == false, "key!"); 163 static_assert( has_slot< KEY, slot::ROTATION >::value == false, "key!"); 164 static_assert( has_slot< KEY, slot::SCALE >::value == false, "key!"); 129 165 return extract_matrix_slot( k.tform ); 130 166 } … … 133 169 mat4 extract_matrix_impl( const KEY& k, const false_type& ) 134 170 { 135 static_assert( key_has_slot< KEY, animation_slot::TFORM >::value == false, "key!");171 static_assert( has_slot< KEY, slot::TFORM >::value == false, "key!"); 136 172 return extract_matrix_prs( k, 137 key_has_slot< KEY, animation_slot::POSITION >(),138 key_has_slot< KEY, animation_slot::ROTATION >(),139 key_has_slot< KEY, animation_slot::SCALE >()173 has_slot< KEY, slot::TRANSLATION >(), 174 has_slot< KEY, slot::ROTATION >(), 175 has_slot< KEY, slot::SCALE >() 140 176 ); 141 177 } … … 144 180 transform extract_transform_impl( const KEY& k, const true_type& ) 145 181 { 146 static_assert( key_has_slot< KEY, animation_slot::POSITION >::value == false, "key!");147 static_assert( key_has_slot< KEY, animation_slot::ROTATION >::value == false, "key!");148 static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!");182 static_assert( has_slot< KEY, slot::TRANSLATION >::value == false, "key!"); 183 static_assert( has_slot< KEY, slot::ROTATION >::value == false, "key!"); 184 static_assert( has_slot< KEY, slot::SCALE >::value == false, "key!"); 149 185 return extract_transfrom_slot( k.tform ); 150 186 } … … 153 189 transform extract_transform_impl( const KEY& k, const false_type& ) 154 190 { 155 static_assert( key_has_slot< KEY, animation_slot::TFORM >::value == false, "key!");156 static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!");191 static_assert( has_slot< KEY, slot::TFORM >::value == false, "key!"); 192 static_assert( has_slot< KEY, slot::SCALE >::value == false, "key!"); 157 193 return extract_transform_pr_impl( k, 158 key_has_slot< KEY, animation_slot::POSITION >(),159 key_has_slot< KEY, animation_slot::ROTATION >()194 has_slot< KEY, slot::TRANSLATION >(), 195 has_slot< KEY, slot::ROTATION >() 160 196 ); 161 197 } … … 165 201 mat4 extract_matrix( const KEY& k ) 166 202 { 167 return detail::extract_matrix_impl( k, key_has_slot< KEY, animation_slot::TFORM >() );203 return detail::extract_matrix_impl( k, has_slot< KEY, slot::TFORM >() ); 168 204 } 169 205 … … 171 207 transform extract_transform( const KEY& k ) 172 208 { 173 return detail::extract_transform_impl( k, key_has_slot< KEY, animation_slot::TFORM >() );209 return detail::extract_transform_impl( k, has_slot< KEY, slot::TFORM >() ); 174 210 } 175 211 -
trunk/nv/interface/mesh_data.hh
r406 r410 11 11 #include <nv/stl/math.hh> 12 12 #include <nv/stl/string.hh> 13 #include <nv/interface/data_descriptor.hh> 13 14 #include <nv/gfx/animation.hh> 14 #include <nv/interface/vertex.hh>15 15 16 16 namespace nv 17 17 { 18 18 19 enum buffer_type 20 { 21 VERTEX_BUFFER, 22 INDEX_BUFFER, 23 }; 24 25 19 26 // TODO: friend mesh_data_creator class? 20 27 // TODO: private const etc … … 25 32 friend class mesh_creator; 26 33 27 vertex_descriptor desc;28 uint8* 29 uint32 34 data_descriptor desc; 35 uint8* data; 36 uint32 count; 30 37 31 38 mesh_raw_channel() : data( nullptr ), count( 0 ) {} … … 38 45 buffer_type get_buffer_type() const 39 46 { 40 if ( count > 0 && desc .slots[0].vslot == slot::INDEX )47 if ( count > 0 && desc[0].vslot == slot::INDEX ) 41 48 { 42 49 return INDEX_BUFFER; … … 45 52 } 46 53 47 uint32 size() const { return count * desc. size; }54 uint32 size() const { return count * desc.element_size(); } 48 55 49 56 template < typename VTX > … … 56 63 return result; 57 64 } 58 static mesh_raw_channel* create( const vertex_descriptor& vtxdesc, uint32 count = 0 )65 static mesh_raw_channel* create( const data_descriptor& vtxdesc, uint32 count = 0 ) 59 66 { 60 67 mesh_raw_channel* result = new mesh_raw_channel(); … … 119 126 for ( auto ch : m_channels ) 120 127 { 121 for ( uint32 i = 0; i < ch->desc.count; ++i ) 122 if ( ch->desc.slots[i].vslot == s ) 123 { 128 for ( auto slot : ch->desc ) 129 if ( slot.vslot == s ) 124 130 return ch; 125 }126 131 } 127 132 return nullptr; … … 132 137 for ( uint32 c = 0; c < m_channels.size(); ++c ) 133 138 { 134 const mesh_raw_channel* ch = m_channels[c]; 135 for ( uint32 i = 0; i < ch->desc.count; ++i ) 136 if ( ch->desc.slots[i].vslot == s ) 137 { 139 for ( auto slot : m_channels[c]->desc ) 140 if ( slot.vslot == s ) 138 141 return int( c ); 139 }140 142 } 141 143 return -1; … … 159 161 const mesh_raw_channel* get_channel() const 160 162 { 161 vertex_descriptor compare;163 data_descriptor compare; 162 164 compare.initialize<VTX>(); 163 165 for ( auto ch : m_channels ) … … 174 176 const VTX* get_channel_data() const 175 177 { 176 vertex_descriptor compare;178 data_descriptor compare; 177 179 compare.initialize<VTX>(); 178 180 for ( auto ch : m_channels ) -
trunk/nv/stl/container/contiguous_storage_policy.hh
r406 r410 50 50 fixed_storage( fixed_storage&& ) = default; 51 51 fixed_storage& operator=( fixed_storage&& ) = default; 52 52 53 }; 53 54 … … 73 74 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 74 75 operator array_view< value_type >() const { return array_view< value_type >( Storage::data(), size() ); } 75 protected: 76 76 77 constexpr resizable_storage() : m_size( 0 ) {} 77 78 protected: 78 79 // allow move 79 80 inline resizable_storage( resizable_storage&& other ) … … 84 85 inline resizable_storage& operator=( resizable_storage&& other ) 85 86 { 87 if ( m_size > 0 ) Storage::reallocate( 0, false ); 86 88 m_size = other.m_size; 87 89 Storage::operator=( nv::move( other ) ); … … 113 115 static SizeType get( SizeType requested, SizeType capacity, SizeType max_size ) 114 116 { 115 SizeType minimum = nv::m in<SizeType>( capacity, 4 );117 SizeType minimum = nv::max<SizeType>( capacity, 4 ); 116 118 SizeType remaining = max_size - capacity; 117 119 if ( remaining < requested ) return 0; … … 142 144 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 143 145 operator array_view< value_type >() const { return array_view< value_type >( Storage::data(), size() ); } 144 protected: 146 145 147 constexpr growable_storage() : m_size( 0 ), m_capacity( 0 ) {} 146 148 protected: 147 149 // allow move 148 150 inline growable_storage( growable_storage&& other ) … … 154 156 inline growable_storage& operator=( growable_storage&& other ) 155 157 { 158 if ( m_capacity > 0 ) Storage::reallocate( 0, false ); 156 159 m_size = other.m_size; 157 160 m_capacity = other.m_capacity; … … 172 175 { 173 176 m_capacity = new_capacity; 174 m_size = new_size;175 177 } 176 178 else return false; … … 184 186 if ( new_capacity > m_capacity ) 185 187 { 186 if ( Storage::reallocate( new_capacity, copy_needed ) )188 if ( new_capacity > 0 && Storage::reallocate( new_capacity, copy_needed ) ) 187 189 { 188 190 m_capacity = new_capacity; -
trunk/nv/stl/container/growing_container_handler.hh
r401 r410 28 28 { 29 29 public: 30 typedef typename growing_container_handler< Storage, InitializePolicy > this_type; 30 31 typedef typename Storage::value_type value_type; 31 32 typedef typename Storage::size_type size_type; 33 typedef value_type* iterator; 34 typedef const value_type* const_iterator; 32 35 33 36 using sized_container_handler< Storage, InitializePolicy >::sized_container_handler; … … 50 53 if ( Storage::try_grow( 1 ) ) construct_object( Storage::data() + Storage::size() - 1, forward<Args>( args )... ); 51 54 } 55 52 56 void pop_back() 53 57 { 58 InitializePolicy::destroy( Storage::data() + Storage::size() - 1 ); 54 59 Storage::try_resize( Storage::size() - 1, true ); 55 60 } 56 61 62 // TODO: implement swap_erase 63 iterator erase( iterator position ) 64 { 65 iterator iend = Storage::data() + Storage::size(); 66 InitializePolicy::destroy( position ); 67 if ( ( position + 1 ) < iend ) 68 raw_alias_copy( position + 1, iend, position ); 69 Storage::try_resize( Storage::size() - 1, true ); 70 return position; 71 } 72 73 iterator erase( iterator first, iterator last ) 74 { 75 iterator iend = Storage::data() + Storage::size(); 76 InitializePolicy::destroy( first, last ); 77 iterator position = raw_alias_copy( last, iend, first ); 78 Storage::try_resize( Storage::size() - ( last - first ), true ); 79 return position; 80 } 81 82 void append( const_iterator first, const_iterator last ) 83 { 84 // TODO: distance can't be called on destructive iterators - check 85 // and use pushback if needed? 86 size_type d = distance( first, last ); 87 size_type old_size = Storage::size(); 88 if ( Storage::try_grow( d ) ) 89 InitializePolicy::copy( first, last, Storage::data() + old_size ); 90 } 91 92 // TODO: This can be much optimized in the grow case by copying in three parts 93 void insert( iterator position, const value_type& value ) 94 { 95 iterator iend = Storage::data() + Storage::size(); 96 if ( Storage::try_grow( 1 ) ) 97 { 98 raw_alias_copy( position, iend, position + 1 ); 99 copy_construct_object( position, value ); 100 } 101 } 102 103 // TODO: This can be much optimized in the grow case by copying in three parts 104 void insert( iterator position, const_iterator first, const_iterator last ) 105 { 106 // TODO: distance can't be called on destructive iterators - check 107 // and use pushback if needed? 108 iterator iend = Storage::data() + Storage::size(); 109 size_type d = distance( first, last ); 110 if ( Storage::try_grow( d ) ) 111 { 112 raw_alias_copy( position, iend, position + d ); 113 InitializePolicy::copy( first, last, position ); 114 } 115 } 57 116 }; 58 117 -
trunk/nv/stl/string.hh
r408 r410 346 346 { 347 347 if ( p > this->size() ) return string_view(); // NV_THROW( out_of_range( "substr" ) ); 348 if ( n == p || p + n > this->size() ) n = this->size() - p;348 if ( n == npos || n == p || p + n > this->size() ) n = this->size() - p; 349 349 return string_view( this->data() + p, n ); 350 350 } -
trunk/nv/stl/type_traits/experimental.hh
r395 r410 43 43 44 44 #if NV_COMPILER == NV_MSVC 45 #define NV_VOID_DECLTYPE( EXPR ) ::nv::match_ptr_t< &EXPR > 45 46 #define NV_GENERATE_HAS_MEMBER( MEMBER ) \ 46 47 template< typename, typename = nv::void_t<> > struct has_##MEMBER##_member : nv::false_type {}; \ 47 template< typename T > struct has_##MEMBER##_member <T, nv::void_t< nv::match_ptr_t< &T::MEMBER >> > : true_type{};48 template< typename T > struct has_##MEMBER##_member <T, nv::void_t< NV_VOID_DECLTYPE( T::MEMBER ) > > : true_type{}; 48 49 #else 50 #define NV_VOID_DECLTYPE( EXPR ) decltype( EXPR ) 49 51 #define NV_GENERATE_HAS_MEMBER( MEMBER ) \ 50 52 template< typename, typename = nv::void_t<> > struct has_##MEMBER##_member : nv::false_type {}; \ 51 template< typename T > struct has_##MEMBER##_member <T, nv::void_t< decltype( T::MEMBER ) > > : true_type{};53 template< typename T > struct has_##MEMBER##_member <T, nv::void_t< NV_VOID_DECLTYPE( T::MEMBER ) > > : true_type{}; 52 54 #endif 53 55 -
trunk/nv/stl/type_traits/transforms.hh
r401 r410 40 40 41 41 template< typename SOURCE, typename TARGET, 42 bool CONST= is_const<SOURCE>::value,43 bool VOLATILE= is_volatile<SOURCE>::value >42 bool IsConst = is_const<SOURCE>::value, 43 bool IsVolatile = is_volatile<SOURCE>::value > 44 44 struct match_cv 45 45 { 46 typedef typename cv_selector< TARGET, CONST, VOLATILE>::type type;46 typedef typename cv_selector< TARGET, IsConst, IsVolatile >::type type; 47 47 }; 48 48 … … 73 73 template<> struct unsigned_type < signed long long > { typedef unsigned long long type; }; 74 74 75 template < typename T, bool I S_ENUM= is_enum< T >::value >75 template < typename T, bool IsEnum = is_enum< T >::value > 76 76 struct make_signed_impl; 77 77 -
trunk/nv/wx/wx_canvas.hh
r395 r410 31 31 virtual int OnExit(); 32 32 virtual bool initialize() = 0; 33 protected: 34 nv::logger m_logger; 33 35 }; 34 36 … … 88 90 public: 89 91 wx_log_text_ctrl_sink( wxTextCtrl* a_text_ctrl ); 90 virtual void log( nv::log_level level, const std::string& message );92 virtual void log( nv::log_level level, const nv::string_view& message ); 91 93 private: 92 94 wxTextCtrl* m_text_ctrl; -
trunk/nv_wx.lua
r352 r410 10 10 solution "*" 11 11 includedirs { 12 " C:/wxwidgets/include/msvc/",13 " C:/wxwidgets/include/",12 "D:/Libraries/wxwidgets/include/msvc/", 13 "D:/Libraries/wxwidgets/include/", 14 14 } 15 libdirs { " C:/wxwidgets/lib/vc120_dll" }15 libdirs { "D:/Libraries/wxwidgets/lib/vc140_dll" } 16 16 defines { "__WXMSW__", "_UNICODE", "WXUSINGDLL", "wxMSVC_VERSION_AUTO" } -
trunk/src/formats/assimp_loader.cc
r406 r410 50 50 }; 51 51 52 struct assimp_key_p { float time; vec3 position; };52 struct assimp_key_p { float time; vec3 translation; }; 53 53 struct assimp_key_r { float time; quat rotation; }; 54 54 struct assimp_key_s { float time; vec3 scale; }; … … 430 430 for ( unsigned np = 0; np < node->mNumPositionKeys; ++np ) 431 431 { 432 pchannel[np].time = static_cast<float>( node->mPositionKeys[np].mTime );433 pchannel[np]. position = assimp_vec3_cast(node->mPositionKeys[np].mValue);432 pchannel[np].time = static_cast<float>( node->mPositionKeys[np].mTime ); 433 pchannel[np].translation = assimp_vec3_cast(node->mPositionKeys[np].mValue); 434 434 } 435 435 for ( unsigned np = 0; np < node->mNumRotationKeys; ++np ) -
trunk/src/formats/nmd_loader.cc
r406 r410 44 44 source.read( &stream_header, sizeof( stream_header ), 1 ); 45 45 mesh_raw_channel* channel = mesh_raw_channel::create( stream_header.format, stream_header.count ); 46 source.read( channel->data, stream_header.format. size, stream_header.count );46 source.read( channel->data, stream_header.format.element_size(), stream_header.count ); 47 47 mesh->add_channel( channel ); 48 48 } … … 126 126 source.read( &element_header, sizeof( element_header ), 1 ); 127 127 NV_ASSERT( element_header.type == nmd_type::KEY_CHANNEL, "CHANNEL expected!" ); 128 nv::nmd_ key_channel_header cheader;128 nv::nmd_stream_header cheader; 129 129 source.read( &cheader, sizeof( cheader ), 1 ); 130 130 key_raw_channel* channel = key_raw_channel::create( cheader.format, cheader.count ); 131 source.read( channel->data, channel->desc. size, channel->count );131 source.read( channel->data, channel->desc.element_size(), channel->count ); 132 132 kdata->add_channel( channel ); 133 133 } … … 191 191 sheader.count = chan->count; 192 192 stream_out.write( &sheader, sizeof( sheader ), 1 ); 193 stream_out.write( chan->data, chan->desc. size, chan->count );193 stream_out.write( chan->data, chan->desc.element_size(), chan->count ); 194 194 } 195 195 } … … 205 205 for ( uint32 c = 0; c < node->data->get_channel_count(); ++c ) 206 206 { 207 total += sizeof( nmd_element_header ) + sizeof( nmd_ key_channel_header );207 total += sizeof( nmd_element_header ) + sizeof( nmd_stream_header ); 208 208 total += node->data->get_channel(c)->size(); 209 209 } … … 230 230 for ( uint32 c = 0; c < chan_count; ++c ) 231 231 { 232 chan_size += sizeof( nmd_element_header ) + sizeof( nv::nmd_ key_channel_header );232 chan_size += sizeof( nmd_element_header ) + sizeof( nv::nmd_stream_header ); 233 233 chan_size += node->data->get_channel(c)->size(); 234 234 } … … 252 252 eheader.type = nmd_type::KEY_CHANNEL; 253 253 eheader.children = 0; 254 eheader.size = sizeof( nmd_ key_channel_header ) + channel->size();254 eheader.size = sizeof( nmd_stream_header ) + channel->size(); 255 255 stream_out.write( &eheader, sizeof( eheader ), 1 ); 256 256 257 nmd_ key_channel_header cheader;257 nmd_stream_header cheader; 258 258 cheader.format = channel->desc; 259 259 cheader.count = channel->count; 260 260 stream_out.write( &cheader, sizeof( cheader ), 1 ); 261 stream_out.write( channel->data, channel->desc. size, channel->count );261 stream_out.write( channel->data, channel->desc.element_size(), channel->count ); 262 262 } 263 263 } -
trunk/src/gfx/keyframed_mesh.cc
r406 r410 192 192 buffer ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), m_mesh_data->get_index_channel()->data ); 193 193 194 m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc .slots[0].etype, true );194 m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc[0].etype, true ); 195 195 196 196 m_data = new uint8[ m_vertex_count * m_vsize ]; -
trunk/src/gfx/mesh_creator.cc
r406 r410 57 57 size_t chan_count = old_keys->get_channel_count(); 58 58 if ( chan_count == 1 59 && old_keys->get_channel(0)->desc. count== 160 && old_keys->get_channel(0)->desc .slots[0].etype == TRANSFORM ) continue;59 && old_keys->get_channel(0)->desc.slot_count() == 1 60 && old_keys->get_channel(0)->desc[0].etype == TRANSFORM ) continue; 61 61 62 62 size_t max_keys = 0; … … 70 70 new_keys->add_channel( raw_channel ); 71 71 nv_key_transform* channel = reinterpret_cast<nv_key_transform*>(raw_channel->data); 72 key_descriptor final_key = old_keys->get_final_key();72 data_descriptor final_key = old_keys->get_final_key(); 73 73 74 74 for ( unsigned n = 0; n < max_keys; ++n ) … … 107 107 { 108 108 const key_raw_channel* channel = kdata->get_channel(c); 109 size_t key_size = channel->desc. size;109 size_t key_size = channel->desc.element_size(); 110 110 for ( size_t n = 0; n < channel->count; ++n ) 111 111 { … … 126 126 { 127 127 const mesh_raw_channel* channel = m_data->get_channel(c); 128 const vertex_descriptor& desc= channel->desc;128 const data_descriptor& desc = channel->desc; 129 129 uint8* raw_data = channel->data; 130 uint32 vtx_size = desc. size;130 uint32 vtx_size = desc.element_size(); 131 131 int p_offset = -1; 132 132 int n_offset = -1; 133 133 int t_offset = -1; 134 for ( uint32 i = 0; i < desc.count; ++i)135 switch ( desc.slots[i].vslot )136 { 137 case slot::POSITION : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) p_offset = int(desc.slots[i].offset); break;138 case slot::NORMAL : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) n_offset = int(desc.slots[i].offset); break;139 case slot::TANGENT : if ( desc.slots[i].etype == FLOAT_VECTOR_4 ) t_offset = int(desc.slots[i].offset); break;134 for ( const auto& cslot : desc ) 135 switch ( cslot.vslot ) 136 { 137 case slot::POSITION : if ( cslot.etype == FLOAT_VECTOR_3 ) p_offset = int( cslot.offset ); break; 138 case slot::NORMAL : if ( cslot.etype == FLOAT_VECTOR_3 ) n_offset = int( cslot.offset ); break; 139 case slot::TANGENT : if ( cslot.etype == FLOAT_VECTOR_4 ) t_offset = int( cslot.offset ); break; 140 140 default : break; 141 141 } … … 174 174 if ( ch_n == -1 ) return; 175 175 mesh_raw_channel* channel = m_data->m_channels[ unsigned( ch_n ) ]; 176 for ( uint32 i = 0; i < channel->desc.count; ++i)177 if ( c hannel->desc.slots[i].vslot == slot::NORMAL )178 { 179 n_offset = c hannel->desc.slots[i].offset;176 for ( const auto& cslot : channel->desc ) 177 if ( cslot.vslot == slot::NORMAL ) 178 { 179 n_offset = cslot.offset; 180 180 } 181 181 182 182 for ( uint32 i = 0; i < channel->count; ++i ) 183 183 { 184 vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc. size* i + n_offset );184 vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc.element_size() * i + n_offset ); 185 185 normal = -normal; 186 186 } … … 204 204 { 205 205 const mesh_raw_channel* channel = m_data->get_channel(c); 206 const vertex_descriptor& desc = channel->desc; 207 for ( uint32 i = 0; i < desc.count; ++i)208 switch ( desc.slots[i].vslot )206 207 for ( const auto& cslot : channel->desc ) 208 switch ( cslot.vslot ) 209 209 { 210 210 case slot::POSITION : 211 if ( desc.slots[i].etype == FLOAT_VECTOR_3 )212 { 213 p_offset = int( desc.slots[i].offset );211 if ( cslot.etype == FLOAT_VECTOR_3 ) 212 { 213 p_offset = int( cslot.offset ); 214 214 p_channel = channel; 215 215 } 216 216 break; 217 case slot::NORMAL : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) 218 { 219 n_offset = int( desc.slots[i].offset ); 217 case slot::NORMAL : 218 if ( cslot.etype == FLOAT_VECTOR_3 ) 219 { 220 n_offset = int( cslot.offset ); 220 221 n_channel = m_data->m_channels[ c ]; 221 222 n_channel_index = c; 222 223 } 223 224 break; 224 case slot::TEXCOORD : if ( desc.slots[i].etype == FLOAT_VECTOR_2 ) 225 { 226 t_offset = int( desc.slots[i].offset ); 225 case slot::TEXCOORD : 226 if ( cslot.etype == FLOAT_VECTOR_2 ) 227 { 228 t_offset = int( cslot.offset ); 227 229 t_channel = channel; 228 230 } … … 230 232 case slot::INDEX : 231 233 { 232 i_type = desc.slots[i].etype;234 i_type = cslot.etype; 233 235 i_channel = channel; 234 236 } … … 278 280 } 279 281 280 const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc. size*ti0 + t_offset );281 const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc. size*ti1 + t_offset );282 const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc. size*ti2 + t_offset );282 const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti0 + t_offset ); 283 const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti1 + t_offset ); 284 const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti2 + t_offset ); 283 285 vec2 st1 = w3 - w1; 284 286 vec2 st2 = w2 - w1; … … 291 293 uint32 nti1 = t_channel->count * set + ti1; 292 294 uint32 nti2 = t_channel->count * set + ti2; 293 vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc. size*nti0 + p_offset );294 vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc. size*nti1 + p_offset );295 vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc. size*nti2 + p_offset );295 vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti0 + p_offset ); 296 vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti1 + p_offset ); 297 vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti2 + p_offset ); 296 298 vec3 xyz1 = v3 - v1; 297 299 vec3 xyz2 = v2 - v1; … … 317 319 for ( unsigned int i = 0; i < vtx_count; ++i ) 318 320 { 319 const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc. size*i + n_offset );321 const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc.element_size()*i + n_offset ); 320 322 const vec3 t = vec3(tangents[i]); 321 323 if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) ) … … 335 337 { 336 338 NV_ASSERT( a->count == b->count, "merge_channel - bad channels!" ); 337 vertex_descriptor adesc = a->desc; 338 vertex_descriptor bdesc = b->desc; 339 uint32 count = a->count; 340 341 vertex_descriptor desc = a->desc; 342 for ( uint32 i = 0; i < bdesc.count; i++ ) 343 { 344 desc.slots[desc.count+i] = bdesc.slots[i]; 345 desc.slots[desc.count+i].offset += desc.size; 346 } 347 desc.size += bdesc.size; 348 desc.count += bdesc.count; 349 uint8* data = new uint8[ count * desc.size ]; 339 data_descriptor adesc = a->desc; 340 data_descriptor bdesc = b->desc; 341 uint32 count = a->count; 342 343 data_descriptor desc = a->desc; 344 for ( auto bslot : bdesc ) 345 { 346 desc.push_slot( bslot.etype, bslot.vslot ); 347 } 348 uint8* data = new uint8[ count * desc.element_size() ]; 350 349 for ( uint32 i = 0; i < count; ++i ) 351 350 { 352 raw_copy_n( a->data + i * adesc. size, adesc.size, data + i*desc.size);353 raw_copy_n( b->data + i * bdesc. size, bdesc.size, data + i*desc.size + adesc.size);351 raw_copy_n( a->data + i * adesc.element_size(), adesc.element_size(), data + i*desc.element_size() ); 352 raw_copy_n( b->data + i * bdesc.element_size(), bdesc.element_size(), data + i*desc.element_size() + adesc.element_size() ); 354 353 } 355 354 mesh_raw_channel* result = new mesh_raw_channel; … … 365 364 if ( a->count % frame_count != 0 ) return nullptr; 366 365 if ( b->count % frame_count != 0 ) return nullptr; 367 size_t vtx_size = a->desc. size;366 size_t vtx_size = a->desc.element_size(); 368 367 369 368 uint8* data = new uint8[ ( a->count + b->count ) * vtx_size ]; … … 435 434 if ( old->get_buffer_type() == INDEX_BUFFER ) 436 435 { 437 switch ( old->desc .slots[0].etype )436 switch ( old->desc[0].etype ) 438 437 { 439 438 case USHORT : -
trunk/src/gl/gl_window.cc
r406 r410 104 104 m_handle = wm->adopt_window( handle ); 105 105 m_hwnd = ::GetDC( reinterpret_cast<HWND>( handle ) ); 106 m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height) );106 m_context->set_viewport( nv::ivec4( 0, 0, 1, 1 ) ); 107 107 #else 108 108 NV_ASSERT( false, "Native GL context adoption not implemented for this platform!" ); -
trunk/src/stl/assert.cc
r406 r410 5 5 // For conditions of distribution and use, see copying.txt file in root folder. 6 6 7 #define NV_BASE_COMMON_HH 8 #define NV_INTERNAL_INCLUDE 9 #include "nv/base/assert.hh" 10 #undef NV_BASE_COMMON_HH 7 #include "nv/base/common.hh" 11 8 #include "nv/core/logging.hh" 12 9 13 10 extern "C" { 14 11 #if NV_COMPILER == NV_MSVC 15 NV_NORETURN void __cdecl exit( _In_ int _Code );12 _ACRTIMP NV_NORETURN void __cdecl exit( _In_ int _Code ); 16 13 #else 17 14 void exit( int status_code ) NV_NORETURN; -
trunk/src/wx/wx_canvas.cc
r395 r410 63 63 } 64 64 65 void nv::wx_log_text_ctrl_sink::log( nv::log_level level, const std::string& message )65 void nv::wx_log_text_ctrl_sink::log( nv::log_level level, const nv::string_view& message ) 66 66 { 67 67 wxString str; 68 str << timestamp() << " [" << padded_level_name( level ) << "] " << message << "\n"; 68 char stamp[16]; 69 size_t ssize = timestamp( stamp ); 70 str << stamp << " [" << padded_level_name( level ).data() << "] " << message.data() << "\n"; 69 71 m_text_ctrl->AppendText( str ); 70 72 } 71 73 72 74 nv::wx_app_base::wx_app_base() 75 : m_logger( nv::LOG_TRACE ) 73 76 { 74 static nv::logger log( nv::LOG_TRACE);75 log.add_sink( new nv::log_file_sink( "log.txt" ), nv::LOG_TRACE );77 nv::log_sink* sink = new nv::log_file_sink( "log.txt" ); 78 m_logger.add_sink( sink, nv::LOG_TRACE ); 76 79 NV_LOG( nv::LOG_NOTICE, "Logging started" ); 77 80 }
Note: See TracChangeset
for help on using the changeset viewer.