4
Copyright (C) 2005-2009 Julien Jorge, Sebastien Angibaud
4
Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
6
6
This program is free software; you can redistribute it and/or modify it
7
7
under the terms of the GNU General Public License as published by the
52
52
bear::universe::physical_item_state::physical_item_state
53
53
( const physical_item_state& that )
54
54
: physical_item_attributes(that), m_fixed(false), m_x_fixed(that.m_x_fixed),
55
m_y_fixed(that.m_y_fixed), m_global(false)
55
m_y_fixed(that.m_y_fixed), m_global(that.m_global)
58
58
} // physical_item_state::physical_item_state()
98
98
/*----------------------------------------------------------------------------*/
100
* \brief Set the bouding box of this item.
101
* \param r the new bounding box of the item.
103
void bear::universe::physical_item_state::set_bounding_box
104
( const bear::universe::rectangle_type& r )
106
set_bottom_left(r.bottom_left());
107
set_size( r.size() );
108
} // physical_item_state::set_bounding_box()
110
/*----------------------------------------------------------------------------*/
100
112
* \brief Get the bouding box of this item.
102
114
bear::universe::rectangle_type
281
293
/*----------------------------------------------------------------------------*/
295
* \brief Get the current angular speed of the item.
297
double bear::universe::physical_item_state::get_angular_speed() const
299
return m_angular_speed;
300
} // physical_item_state::get_angular_speed()
302
/*----------------------------------------------------------------------------*/
304
* \brief Set the current angular speed of the item.
306
void bear::universe::physical_item_state::set_angular_speed( double speed )
308
m_angular_speed = speed;
309
} // physical_item_state::set_angular_speed()
311
/*----------------------------------------------------------------------------*/
283
313
* \brief Get the friction applied to this item.
285
315
double bear::universe::physical_item_state::get_friction() const
696
726
/*----------------------------------------------------------------------------*/
698
728
* \brief Set (force) the position of the center of the item.
729
* \param pos The new center of mass.
700
731
void bear::universe::physical_item_state::set_center_of_mass
701
732
( const position_type& pos )
706
737
/*----------------------------------------------------------------------------*/
739
* \brief Set (force) the position of the center of the item.
740
* \param x The new x_coordinate of the center of mass.
741
* \param y The new y-coordinate of the center of mass.
743
void bear::universe::physical_item_state::set_center_of_mass
744
( const coordinate_type& x, const coordinate_type& y )
746
set_center_of_mass( position_type(x,y) );
747
} // physical_item_state::set_center_of_mass()
749
/*----------------------------------------------------------------------------*/
708
751
* \brief Tell if the item is fixed.
710
753
bool bear::universe::physical_item_state::is_fixed() const
897
940
/*----------------------------------------------------------------------------*/
899
942
* \brief Tell that the item has a contact on its left.
943
* \param contact The new contact status.
901
void bear::universe::physical_item_state::set_left_contact()
945
void bear::universe::physical_item_state::set_left_contact(bool contact)
903
m_left_contact = true;
947
m_left_contact = contact;
904
948
} // physical_item_state::set_left_contact()
906
950
/*----------------------------------------------------------------------------*/
908
952
* \brief Tell that the item has a contact on its right.
953
* \param contact The new contact status.
910
void bear::universe::physical_item_state::set_right_contact()
955
void bear::universe::physical_item_state::set_right_contact(bool contact)
912
m_right_contact = true;
957
m_right_contact = contact;
913
958
} // physical_item_state::set_right_contact()
915
960
/*----------------------------------------------------------------------------*/
917
962
* \brief Tell that the item has a contact on its top.
963
* \param contact The new contact status.
919
void bear::universe::physical_item_state::set_top_contact()
965
void bear::universe::physical_item_state::set_top_contact(bool contact)
921
m_top_contact = true;
967
m_top_contact = contact;
922
968
} // physical_item_state::set_top_contact()
924
970
/*----------------------------------------------------------------------------*/
926
972
* \brief Tell that the item has a contact on its bottom.
973
* \param contact The new contact status.
928
void bear::universe::physical_item_state::set_bottom_contact()
975
void bear::universe::physical_item_state::set_bottom_contact(bool contact)
930
m_bottom_contact = true;
977
m_bottom_contact = contact;
931
978
} // physical_item_state::set_bottom_contact()
933
980
/*----------------------------------------------------------------------------*/
935
982
* \brief Tell that the item has a contact in middle zone.
983
* \param contact The new contact status.
937
void bear::universe::physical_item_state::set_middle_contact()
985
void bear::universe::physical_item_state::set_middle_contact(bool contact)
939
m_middle_contact = true;
987
m_middle_contact = contact;
940
988
} // physical_item_state::set_middle_contact()
942
990
/*----------------------------------------------------------------------------*/
992
1040
/*----------------------------------------------------------------------------*/
1042
* \brief Indicate if the item is considered for weak or strong collisions.
1043
* \param w The new status.
1045
void bear::universe::physical_item_state::set_weak_collisions( bool w )
1047
m_weak_collisions = w;
1048
} // physical_item_state::set_weak_collisions()
1050
/*----------------------------------------------------------------------------*/
1052
* \brief Tell if the item has to be considered as weak collisions.
1053
* \param w The new status.
1055
bool bear::universe::physical_item_state::has_weak_collisions() const
1057
return m_weak_collisions;
1058
} // physical_item_state::has_weak_collisions()
1060
/*----------------------------------------------------------------------------*/
994
1062
* \brief Set the size of the object.
995
1063
* \param size The new size.
1019
1087
void bear::universe::physical_item_state::set_width( size_type width )
1089
if (!m_fixed && (m_x_fixed == 0))
1022
1091
} // physical_item_state::set_width()
1024
1093
/*----------------------------------------------------------------------------*/
1029
1098
void bear::universe::physical_item_state::set_height( size_type height )
1100
if (!m_fixed && (m_y_fixed == 0))
1032
1102
} // physical_item_state::set_height()
1034
1104
/*----------------------------------------------------------------------------*/
1073
1143
oss << "\ndensity: " << m_density;
1074
1144
oss << "\nangle: " << m_system_angle;
1075
1145
oss << "\nfixed: " << m_fixed << ' ' << m_x_fixed << ' ' << m_y_fixed;
1076
oss << "\ncan move items: " << m_can_move_items;
1146
oss << "\nphantom/c.m.i./art.: " << m_is_phantom << ' ' << m_can_move_items
1147
<< ' ' << m_is_artificial;
1077
1148
oss << "\ncontact after collision: " << m_contact_after_collision;
1078
1149
oss << "\ncontact: { ";