Changeset 527 for trunk


Ignore:
Timestamp:
11/03/16 00:51:07 (9 years ago)
Author:
epyon
Message:
  • physics update
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/bullet/bullet_world.hh

    r525 r527  
    2727                virtual collision_shape create_sphere( float radius );
    2828                virtual collision_shape create_capsule( float radius, float height );
     29                virtual collision_shape create_cylinder( const vec3& half_extents );
    2930                virtual collision_shape create_box( const vec3& half_extens );
    3031                virtual collision_shape create_static_plane( const vec3& norm, float cst );
  • trunk/nv/engine/model_manager.hh

    r525 r527  
    3939                MNF_STATIC,
    4040        };
     41
     42        enum class phx_shape
     43        {
     44                BOX,
     45                CYLINDER,
     46        };
     47
    4148
    4249        struct model;
     
    5764                float                        chance    = 1.0f;
    5865                flags<16,uint16>             nflags;
     66                vec3                         phx_hextents;
     67                vec3                         phx_offset;
     68                float                        phx_mass  = 0.0f;
     69                phx_shape                    phx_shape = phx_shape::BOX;
    5970                model_node_choice            choice    = model_node_choice::ALL;
    6071
     
    6879                        target->position  = position;
    6980
     81                        target->phx_hextents = phx_hextents;
     82                        target->phx_offset   = phx_offset;
     83                        target->phx_mass     = phx_mass;
     84                        target->phx_shape    = phx_shape;
    7085                        target->attach_id = attach_id;
    7186                        target->weight    = weight;
     
    101116                sint16                       parent_id;
    102117                transform                                        local;
     118                vec3                         phx_hextents;
     119                vec3                         phx_offset;
     120                float                        phx_mass;
     121                phx_shape                    phx_shape;
    103122                uint32                       gflags;
    104123        };
     
    117136        NV_RTTI_DECLARE_NAME( model_node_flags, "model_node_flags" )
    118137        NV_RTTI_DECLARE_NAME( model, "model" )
     138        NV_RTTI_DECLARE_NAME( phx_shape, "phx_shape" )
    119139
    120140        enum flat_model_flags
     
    163183                        result.count = 0;
    164184                        result.phx_mesh = m->phx_mesh;
    165                         flatten( result, m, rng, control, transform(), -1, map, gen_flags, 0, select );
     185                        flatten( result, m, rng, control, transform(), transform(), -1, map, gen_flags, 0, select );
    166186                        return result;
    167187                }
     
    173193                        ivec2 control,
    174194                        const transform& ptr,
    175                         sint16 parent_id,
     195                        const transform& fptr,
     196                        sint16 parent_id,
    176197                        vector< const model_node* >* map,
    177198                        uint32 gen_flags,
     
    188209                                                return;
    189210                                }
    190                         transform tr = m->local;
     211
     212                        bool skip_static = ( gen_flags & FF_GENERATE_NSTATIC ) && m->nflags[MNF_STATIC];
     213                        bool parse_mesh = ( ( m->mesh || !m->tag.empty() ) && !skip_static ) || ( m->nflags[MNF_FORCE] );
     214
     215                        transform tr = fptr * m->local;
    191216                        if ( !(gen_flags & FF_GENERATE_NLOCAL) )
    192217                                tr = ptr * tr;
     218
     219
    193220                        vec3 position = rng.eval( m->position );
    194221                        vec3 rotation = rng.eval( m->rotation );
     
    202229                                        return;
    203230
    204                         bool skip_static = ( gen_flags & FF_GENERATE_NSTATIC ) && m->nflags[MNF_STATIC];
    205 
    206                         if ( ( ( m->mesh || !m->tag.empty() ) && !skip_static ) || ( m->nflags[MNF_FORCE] ) )
     231                        transform ftr;
     232                        if ( !parse_mesh && ( gen_flags & FF_GENERATE_NLOCAL ) )
     233                        {
     234                                ftr = tr;
     235                        }
     236
     237
     238                        if ( parse_mesh )
    207239                        {
    208240                                uint32 id = result.count++;
     
    215247                                re.attach_id = m->attach_id;
    216248                                re.gflags = parent_flags;
     249                                re.phx_hextents = m->phx_hextents;
     250                                re.phx_offset   = m->phx_offset;
     251                                re.phx_mass     = m->phx_mass;
     252                                re.phx_shape    = m->phx_shape;
     253
    217254                                if ( map ) map->push_back( m );
    218255                                parent_id = sint16(id);
     
    273310                                                uint32 flags = parent_flags;
    274311                                                if ( c != pick ) flags |= FMF_FAIL_CHOICE;
    275                                                 flatten( result, c, rng, control, tr, parent_id, map, gen_flags, flags, selected );
     312                                                flatten( result, c, rng, control, tr, ftr, parent_id, map, gen_flags, flags, selected );
    276313                                        }
    277314                                else
    278                                         flatten( result, pick, rng, control, tr, parent_id, map, gen_flags, parent_flags, selected );
     315                                        flatten( result, pick, rng, control, tr, ftr, parent_id, map, gen_flags, parent_flags, selected );
    279316                        }
    280317                        else
    281318                                for ( auto c : m->children )
    282319                                {
    283                                         flatten( result, c, rng, control, tr, parent_id, map, gen_flags, parent_flags, selected );
     320                                        flatten( result, c, rng, control, tr, ftr, parent_id, map, gen_flags, parent_flags, selected );
    284321                                }
    285322                }
  • trunk/nv/interface/physics_world.hh

    r525 r527  
    7171                virtual collision_shape create_sphere( float radius ) = 0;
    7272                virtual collision_shape create_capsule( float radius, float height ) = 0;
     73                virtual collision_shape create_cylinder( const vec3& half_extens ) = 0;
    7374                virtual collision_shape create_box( const vec3& half_extens ) = 0;
    7475                virtual collision_shape create_static_plane( const vec3& norm, float cst ) = 0;
  • trunk/src/bullet/bullet_world.cc

    r525 r527  
    8888{
    8989        return collision_shape{ ( void* )new btCapsuleShape( radius, height ) };
     90}
     91
     92nv::collision_shape nv::bullet_world::create_cylinder( const vec3& half_extents )
     93{
     94        return collision_shape{ ( void* )new btCylinderShape( n2b( half_extents ) ) };
    9095}
    9196
  • trunk/src/engine/model_manager.cc

    r526 r527  
    8585        }
    8686
     87        if ( table.has_field( "phx_hextents" ) )
     88                node->phx_hextents = table.get<vec3>( "phx_hextents", vec3() );
     89        if ( table.has_field( "phx_offset" ) )
     90                node->phx_offset = table.get<vec3>( "phx_offset", vec3() );
     91        if ( table.has_field( "phx_mass" ) )
     92                node->phx_mass = table.get<float>( "phx_mass", 0.0f);
     93        if ( table.has_field( "phx_mass" ) )
     94                node->phx_shape = nv::phx_shape( table.get<int>( "phx_shape", 0 ) );
     95
    8796        if ( table.has_field( "local_position" ) )
    8897                node->local.set_position( table.get<vec3>( "local_position", vec3() ) );
Note: See TracChangeset for help on using the changeset viewer.