- Timestamp:
- 10/30/15 15:02:06 (10 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/core/resource.hh
r478 r479 63 63 template < typename T > 64 64 friend class resource_lock; 65 65 // friend class resource_manager; 66 66 }; 67 67 … … 72 72 public: 73 73 resource() : m_id(0), m_handler( nullptr ) {} 74 bool is_valid() const { return m_id.valid() && m_handler != nullptr; }75 74 resource_id id() const { return m_id; } 75 constexpr bool is_valid() const { return m_id && m_handler; } 76 constexpr explicit operator bool() const { return is_valid(); } 76 77 ~resource() 77 78 { … … 184 185 // } 185 186 // 186 // virtual const void* create( resource_id id, resource_type_id type_hash )187 // {188 // auto handler = m_handlers.find( type_hash );189 // NV_ASSERT( handler != m_handlers.end(), "Handler not registered!" );190 // return handler->second->create( id, type_hash );191 // }187 // // virtual const void* create( resource_id id, resource_type_id type_hash ) 188 // // { 189 // // auto handler = m_handlers.find( type_hash ); 190 // // NV_ASSERT( handler != m_handlers.end(), "Handler not registered!" ); 191 // // return handler->second->create( id, type_hash ); 192 // // } 192 193 // 193 194 // virtual void unlock( resource_id id, resource_type_id type_hash ) -
trunk/nv/engine/resource_system.hh
r477 r479 115 115 } 116 116 117 118 117 virtual void clear() 119 118 { … … 124 123 } 125 124 m_store.clear(); 125 } 126 127 resource_type add( shash64 id, stored_type resource ) 128 { 129 m_store[id] = resource; 130 return create< T >( id ); 126 131 } 127 132 … … 139 144 virtual void release( stored_type ) {} 140 145 141 void add( stored_type resource, shash64 id )142 {143 m_store[id] = resource;144 }145 146 146 hash_store< shash64, stored_type > m_store; 147 147 }; -
trunk/nv/gfx/skeleton_instance.hh
r477 r479 59 59 60 60 dynamic_array< mat4 > m_transform; 61 };61 }; 62 62 63 63 -
trunk/nv/stl/functional/hash.hh
r472 r479 176 176 constexpr hash_value( const hash_value& ) = default; 177 177 178 constexpr bool valid() const { return m_value != 0; } 178 constexpr bool is_valid() const { return m_value != 0; } 179 constexpr explicit operator bool() const { return is_valid(); } 179 180 180 181 template < typename H2, typename Tag2 > -
trunk/nv/stl/handle.hh
r451 r479 30 30 typedef T value_type; 31 31 typedef TAG tag_type; 32 static const int INDEX_BITS = IBITS; 33 static const int COUNTER_BITS = IBITS; 34 static const T MAX_INDEX = (1 << IBITS) - 1; 35 static const T MAX_COUNTER = (1 << CBITS) - 1; 36 37 handle() : m_index(0), m_counter(0) {} 38 39 inline bool operator==(const handle& rhs) const {return m_index == rhs.m_index && m_counter == rhs.m_counter; } 40 inline bool operator!=(const handle& rhs) const {return !(*this == rhs);} 41 42 bool is_nil() const { return m_index == 0 && m_counter == 0; } 43 bool is_valid() const { return !is_nil(); } 44 T index() const { return m_index; } 32 static constexpr int INDEX_BITS = IBITS; 33 static constexpr int COUNTER_BITS = IBITS; 34 static constexpr T MAX_INDEX = (1 << IBITS) - 1; 35 static constexpr T MAX_COUNTER = (1 << CBITS) - 1; 36 37 constexpr handle() : m_index(0), m_counter(0) {} 38 39 constexpr inline bool operator==(const handle& rhs) const {return m_index == rhs.m_index && m_counter == rhs.m_counter; } 40 constexpr inline bool operator!=(const handle& rhs) const {return !(*this == rhs);} 41 42 constexpr bool is_nil() const { return m_index == 0 && m_counter == 0; } 43 constexpr bool is_valid() const { return !is_nil(); } 44 constexpr operator bool() const { return is_valid(); } 45 46 constexpr T index() const { return m_index; } 45 47 //size_t hash() const { return hash<T>()( T( m_counter << IBITS | m_index ) ); } 46 size_t hash() const { NV_ASSERT( false, "UNIMPLEMENTED!" ); return 0; }48 constexpr size_t hash() const { NV_ASSERT( false, "UNIMPLEMENTED!" ); return 0; } 47 49 protected: 48 50 T m_index : IBITS; 49 51 T m_counter : CBITS; 50 52 51 handle( T a_index, T a_counter ) : m_index( a_index ), m_counter( a_counter ) {}53 constexpr handle( T a_index, T a_counter ) : m_index( a_index ), m_counter( a_counter ) {} 52 54 template < typename H > 53 55 friend class handle_operator; -
trunk/src/engine/particle_engine.cc
r471 r479 303 303 { 304 304 shash64 id = table.get_string_hash_64( "id" ); 305 if ( !id .valid())305 if ( !id ) 306 306 { 307 307 NV_LOG_ERROR( "Bad table passed to particle_engine!" ) -
trunk/src/engine/program_manager.cc
r477 r479 36 36 } 37 37 38 add( m_context->get_device()->create_program( vsource, fsource ), id);38 add( id, m_context->get_device()->create_program( vsource, fsource ) ); 39 39 return true; 40 40 } -
trunk/src/gfx/skeletal_mesh.cc
r477 r479 15 15 void nv::skeletal_animation_entry::update_skeleton( skeleton_instance& data, uint32 a_ms_time ) const 16 16 { 17 float fframe = ( a_ms_time * 0.001f ) * m_fps; 18 uint32 frame = uint32( math::floor( fframe ) ); 19 float reminder = fframe - static_cast<float>( frame ); 17 float fframe = ( a_ms_time * 0.001f ) * m_fps; 18 float nframe = nv::floor( fframe ); 20 19 uint32 duration = get_frame_count(); 21 20 if ( duration == 0 ) 22 21 { 23 frame = get_start_frame(); 24 fframe = static_cast<float>( frame ); 22 fframe = static_cast<float>( get_start_frame() ); 25 23 } 26 else if ( frame >= duration )24 else if ( nframe >= duration ) 27 25 { 28 26 if ( is_looping() ) 29 { 30 frame = frame % duration; 31 fframe = static_cast<float>( frame ) + reminder; 32 } 27 fframe = nv::fmodf( fframe, nv::f32( duration ) ); 33 28 else 34 { 35 frame = get_end_frame(); 36 fframe = static_cast<float>( frame ); 37 } 29 fframe = static_cast<float>( get_end_frame() ); 38 30 } 39 31
Note: See TracChangeset
for help on using the changeset viewer.