* support negative misc_model scale
This commit is contained in:
parent
427ef0874b
commit
31e7829e2b
|
|
@ -1125,6 +1125,17 @@ inline Vector3 matrix4_get_scale_vec3( const Matrix4& self ){
|
|||
);
|
||||
}
|
||||
|
||||
/// \brief Calculates and returns signed (x, y, z) scale values that produce the scale component of \p self.
|
||||
/// \p self must be affine and orthogonal to produce a meaningful result.
|
||||
/// \p self must not contain rotation to produce meaningful signs.
|
||||
inline Vector3 matrix4_get_scale_vec3_signed( const Matrix4& self ){
|
||||
return Vector3(
|
||||
static_cast<float>( std::copysign( vector3_length( self.x().vec3() ), vector3_dot( self.x().vec3(), g_vector3_axis_x ) ) ),
|
||||
static_cast<float>( std::copysign( vector3_length( self.y().vec3() ), vector3_dot( self.y().vec3(), g_vector3_axis_y ) ) ),
|
||||
static_cast<float>( std::copysign( vector3_length( self.z().vec3() ), vector3_dot( self.z().vec3(), g_vector3_axis_z ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
/// \brief Scales \p self by \p scale.
|
||||
inline void matrix4_scale_by_vec3( Matrix4& self, const Vector3& scale ){
|
||||
matrix4_multiply_by_matrix4( self, matrix4_scale_for_vec3( scale ) );
|
||||
|
|
|
|||
|
|
@ -311,12 +311,27 @@ public:
|
|||
}
|
||||
void scale( const Vector3& scaling ){
|
||||
//m_scale = scale_scaled( m_scale, scaling );
|
||||
|
||||
#if 1
|
||||
const Matrix4 rot = matrix4_rotation_for_euler_xyz_degrees( m_anglesKey.m_angles );
|
||||
m_scale = matrix4_get_scale_vec3_signed(
|
||||
matrix4_multiplied_by_matrix4(
|
||||
matrix4_affine_inverse( rot ),
|
||||
matrix4_multiplied_by_matrix4(
|
||||
matrix4_scale_for_vec3( scaling ),
|
||||
matrix4_multiplied_by_matrix4(
|
||||
rot,
|
||||
matrix4_scale_for_vec3( m_scale )
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
#else
|
||||
Matrix4 mat( matrix4_scale_for_vec3( scaling ) );
|
||||
matrix4_multiply_by_matrix4( mat, matrix4_rotation_for_euler_xyz_degrees( m_anglesKey.m_angles ) );
|
||||
matrix4_scale_by_vec3( mat, m_scale );
|
||||
|
||||
m_scale = matrix4_get_scale_vec3( mat );
|
||||
#endif
|
||||
//m_angles = angles_snapped_to_zero( matrix4_get_rotation_euler_xyz_degrees( mat ) );
|
||||
}
|
||||
void snapto( float snap ){
|
||||
|
|
|
|||
|
|
@ -362,6 +362,7 @@ std::vector<const AssMeshWalker*> LoadModelWalker( const char *name, int frame )
|
|||
void InsertModel( const char *name, int skin, int frame, const Matrix4& transform, const std::list<remap_t> *remaps, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle, float clipDepth ){
|
||||
int i, j, k;
|
||||
const Matrix4 nTransform( matrix4_for_normal_transform( transform ) );
|
||||
const bool transform_lefthanded = MATRIX4_LEFTHANDED == matrix4_handedness( transform );
|
||||
AssModel *model;
|
||||
shaderInfo_t *si;
|
||||
mapDrawSurface_t *ds;
|
||||
|
|
@ -622,6 +623,9 @@ void InsertModel( const char *name, int skin, int frame, const Matrix4& transfor
|
|||
for ( size_t i = 0; i < 3; i++ ){
|
||||
ds->indexes[idCopied++] = face.mIndices[i];
|
||||
}
|
||||
if( transform_lefthanded ){
|
||||
std::swap( ds->indexes[idCopied - 1], ds->indexes[idCopied - 2] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user