misc...
	* restrict unwanted angle(s) keys commits on moving generic, eclassmodel, miscmodel entities
	* reverted angle(s), origin, scale entity keys save format from %f to %g
	* fix uniform rotation operations for generic entities with angles key
	* use more precise meth for rotating point entities with only angle rotated
	* snap tiny inaccuracies in angle(s) and origin point entities keys
	* workaround: don't discard empty group ents, having origin key
	* entity class convertion: prevent converting worldspawn; prevent converting point entity to empty group
This commit is contained in:
Garux
2017-08-02 09:43:35 +03:00
parent 9613511560
commit 335dcb2fa8
13 changed files with 114 additions and 44 deletions

View File

@@ -52,7 +52,7 @@ inline void write_angle( float angle, Entity* entity ){
else
{
char value[64];
sprintf( value, "%f", angle );
sprintf( value, "%g", angle );
entity->setKeyValue( "angle", value );
}
}
@@ -79,13 +79,19 @@ void write( Entity* entity ) const {
}
};
inline float float_snapped_to_zero( float value ){
return fabs( value ) < 1e-6 ? 0.f : value;
}
inline float angle_rotated( float angle, const Quaternion& rotation ){
return matrix4_get_rotation_euler_xyz_degrees(
matrix4_multiplied_by_matrix4(
matrix4_rotation_for_z_degrees( angle ),
matrix4_rotation_for_quaternion_quantised( rotation )
)
).z();
return float_snapped_to_zero(
matrix4_get_rotation_euler_xyz_degrees(
matrix4_multiplied_by_matrix4(
matrix4_rotation_for_quaternion_quantised( rotation ),
matrix4_rotation_for_z_degrees( angle )
)
).z()
);
}
#endif