*/
#include "brush_primit.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
void BPMatMul( float A[2][3], float B[2][3], float C[2][3] );
// apply a rotation (degrees)
void BPMatRotate( float A[2][3], float theta );
-#ifdef _DEBUG
+#if GDEF_DEBUG
void BPMatDump( float A[2][3] );
#endif
-#ifdef _DEBUG
+#if GDEF_DEBUG
//#define DBG_BP
#endif
bounds.extents.z() = 1;
// the bounds of a perfectly fitted texture transform
- AABB perfect( Vector3( s_repeat * 0.5, t_repeat * 0.5, 0 ), Vector3( s_repeat * 0.5, t_repeat * 0.5, 1 ) );
+ AABB perfect;
+ if( t_repeat == 0 && s_repeat == 0 ){
+ //bad user's input
+ t_repeat = s_repeat = 1;
+ perfect.origin = Vector3( s_repeat * 0.5, t_repeat * 0.5, 0 );
+ perfect.extents = Vector3( s_repeat * 0.5, t_repeat * 0.5, 1 );
+ }
+ if( t_repeat == 0 ){
+ //fit width
+ perfect.origin = Vector3( s_repeat * 0.5, s_repeat * 0.5 * bounds.extents.y() / bounds.extents.x(), 0 );
+ perfect.extents = Vector3( s_repeat * 0.5, s_repeat * 0.5 * bounds.extents.y() / bounds.extents.x(), 1 );
+ }
+ else if( s_repeat == 0 ){
+ //fit height
+ perfect.origin = Vector3( t_repeat * 0.5 * bounds.extents.x() / bounds.extents.y(), t_repeat * 0.5, 0 );
+ perfect.extents = Vector3( t_repeat * 0.5 * bounds.extents.x() / bounds.extents.y(), t_repeat * 0.5, 1 );
+ }
+ else{
+ perfect.origin = Vector3( s_repeat * 0.5, t_repeat * 0.5, 0 );
+ perfect.extents = Vector3( s_repeat * 0.5, t_repeat * 0.5, 1 );
+ }
// the difference between the current texture transform and the perfectly fitted transform
Matrix4 matrix( matrix4_translation_for_vec3( bounds.origin - perfect.origin ) );
Vector3 first = from;
Vector3 second = to;
- if ( vector3_dot( from, plane.normal() ) > 0 == vector3_dot( to, plane.normal() ) > 0 ) {
+ if ( (vector3_dot( from, plane.normal() ) > 0) == (vector3_dot( to, plane.normal() ) > 0) ) {
first = vector3_negated( first );
second = vector3_negated( second );
}
Matrix4 swap = matrix4_swap_axes( first, second );
- Matrix4 tmp = matrix4_reflection_for_plane( plane );
-
swap.tx() = -static_cast<float>( -2 * plane.a * plane.d );
swap.ty() = -static_cast<float>( -2 * plane.b * plane.d );
swap.tz() = -static_cast<float>( -2 * plane.c * plane.d );