misc...
	* place created simple patch mesh not in middle of bbox, but on edge to make result more usable
	* prefs-interface-layout-single scrollable toolbar
This commit is contained in:
Garux 2017-08-02 09:47:35 +03:00
parent da43652df1
commit fb7c979d42
5 changed files with 109 additions and 79 deletions

View File

@ -309,28 +309,7 @@ inline void matrix4_multiply_by_matrix4( Matrix4& self, const Matrix4& other ){
/// \brief Returns \p self pre-multiplied by \p other.
inline Matrix4 matrix4_premultiplied_by_matrix4( const Matrix4& self, const Matrix4& other ){
#if 1
return matrix4_multiplied_by_matrix4( other, self );
#else
return Matrix4(
self[0] * other[0] + self[1] * other[4] + self[2] * other[8] + self[3] * other[12],
self[0] * other[1] + self[1] * other[5] + self[2] * other[9] + self[3] * other[13],
self[0] * other[2] + self[1] * other[6] + self[2] * other[10] + self[3] * other[14],
self[0] * other[3] + self[1] * other[7] + self[2] * other[11] + self[3] * other[15],
self[4] * other[0] + self[5] * other[4] + self[6] * other[8] + self[7] * other[12],
self[4] * other[1] + self[5] * other[5] + self[6] * other[9] + self[7] * other[13],
self[4] * other[2] + self[5] * other[6] + self[6] * other[10] + self[7] * other[14],
self[4] * other[3] + self[5] * other[7] + self[6] * other[11] + self[7] * other[15],
self[8] * other[0] + self[9] * other[4] + self[10] * other[8] + self[11] * other[12],
self[8] * other[1] + self[9] * other[5] + self[10] * other[9] + self[11] * other[13],
self[8] * other[2] + self[9] * other[6] + self[10] * other[10] + self[11] * other[14],
self[8] * other[3] + self[9] * other[7] + self[10] * other[11] + self[11] * other[15],
self[12] * other[0] + self[13] * other[4] + self[14] * other[8] + self[15] * other[12],
self[12] * other[1] + self[13] * other[5] + self[14] * other[9] + self[15] * other[13],
self[12] * other[2] + self[13] * other[6] + self[14] * other[10] + self[15] * other[14],
self[12] * other[3] + self[13] * other[7] + self[14] * other[11] + self[15] * other[15]
);
#endif
}
/// \brief Pre-multiplies \p self by \p other in-place.
@ -375,29 +354,7 @@ inline void matrix4_affine_multiply_by_matrix4( Matrix4& self, const Matrix4& ot
/// \brief Returns \p self pre-multiplied by \p other.
/// \p self and \p other must be affine.
inline Matrix4 matrix4_affine_premultiplied_by_matrix4( const Matrix4& self, const Matrix4& other ){
#if 1
return matrix4_affine_multiplied_by_matrix4( other, self );
#else
return Matrix4(
self[0] * other[0] + self[1] * other[4] + self[2] * other[8],
self[0] * other[1] + self[1] * other[5] + self[2] * other[9],
self[0] * other[2] + self[1] * other[6] + self[2] * other[10],
0,
self[4] * other[0] + self[5] * other[4] + self[6] * other[8],
self[4] * other[1] + self[5] * other[5] + self[6] * other[9],
self[4] * other[2] + self[5] * other[6] + self[6] * other[10],
0,
self[8] * other[0] + self[9] * other[4] + self[10] * other[8],
self[8] * other[1] + self[9] * other[5] + self[10] * other[9],
self[8] * other[2] + self[9] * other[6] + self[10] * other[10],
0,
self[12] * other[0] + self[13] * other[4] + self[14] * other[8] + other[12],
self[12] * other[1] + self[13] * other[5] + self[14] * other[9] + other[13],
self[12] * other[2] + self[13] * other[6] + self[14] * other[10] + other[14],
1
)
);
#endif
}
/// \brief Pre-multiplies \p self by \p other in-place.

View File

@ -641,13 +641,22 @@ inline Plane3 Plane3_applyTranslation( const Plane3& plane, const Vector3& trans
return Plane3( tmp.normal(), -tmp.dist() );
}
/// lets say M is a transformation matrix, then transforming vertex v is just M*v
/// but transforming the normal is M^(-T) n
inline Plane3 Plane3_applyTransform( const Plane3& plane, const Matrix4& matrix ){
/* fails for scaling */
//Plane3 tmp( plane3_transformed( Plane3( plane.normal(), -plane.dist() ), matrix ) );
//return Plane3( tmp.normal(), -tmp.dist() );
Vector4 anchor = matrix4_transformed_vector4( matrix, Vector4( plane.normal() * plane.dist(), 1 ) );
Matrix4 mat = matrix4_transposed( matrix4_full_inverse( matrix ) );
Vector4 normal = matrix4_transformed_vector4( mat, Vector4( plane.normal(), 0 ) );
return plane3_normalised( Plane3( vector4_to_vector3( normal ), vector3_dot( vector4_to_vector3( normal ), vector4_to_vector3( anchor ) ) ) );
/* ok */
// Vector4 anchor = matrix4_transformed_vector4( matrix, Vector4( plane.normal() * plane.dist(), 1 ) );
// Matrix4 mat = matrix4_transposed( matrix4_full_inverse( matrix ) );
// Vector4 normal = matrix4_transformed_vector4( mat, Vector4( plane.normal(), 0 ) );
// return plane3_normalised( Plane3( vector4_to_vector3( normal ), vector3_dot( vector4_to_vector3( normal ), vector4_to_vector3( anchor ) ) ) );
const Vector3 anchor( matrix4_transformed_point( matrix, plane.normal() * plane.dist() ) );
const Matrix4 mat( matrix4_transposed( matrix4_affine_inverse( matrix ) ) );
const Vector3 normal( vector3_normalised( matrix4_transformed_direction( mat, plane.normal() ) ) );
return Plane3( normal, vector3_dot( normal, anchor ) );
}
class FacePlane
@ -2681,7 +2690,7 @@ void selectPlane( Selector& selector, const Line& line, const PlaneCallback& sel
{
Vector3 v( vector3_subtracted( line_closest_point( line, ( *i ).vertex ), ( *i ).vertex ) );
double dot = vector3_dot( getFace().plane3().normal(), v );
//globalOutputStream() << dot << "\n";
// globalOutputStream() << getFace().plane3().normal()[0] << " " << getFace().plane3().normal()[1] << " " << getFace().plane3().normal()[2] << " DOT " << dot << "\n";
//epsilon to prevent perpendicular faces pickup
if ( dot <= 0.005 ) {
return;

View File

@ -1448,16 +1448,23 @@ inline Matrix4 matrix4_reflection_for_plane45( const Plane3& plane, const Vector
}
void Texdef_transformLocked( TextureProjection& projection, std::size_t width, std::size_t height, const Plane3& plane, const Matrix4& identity2transformed ){
if( identity2transformed == g_matrix4_identity ) return; //TODO FIXME !!! this is called with g_matrix4_identity after every transform (and whole pipeline?)
// globalOutputStream() << "\t\t----------------------\n";
// globalOutputStream() << "AP: scale[0]:" << projection.m_texdef.scale[0] << " scale[1]:" << projection.m_texdef.scale[1] << " shift[0]:" << projection.m_texdef.shift[0] << " shift[1]:" << projection.m_texdef.shift[1] << " rotate:" << projection.m_texdef.rotate << "\n";
// globalOutputStream() << "BP: coords[0][0]:" << projection.m_brushprimit_texdef.coords[0][0] << " coords[0][1]:" << projection.m_brushprimit_texdef.coords[0][1] << " coords[0][2]:" << projection.m_brushprimit_texdef.coords[0][2] << " coords[1][0]:" << projection.m_brushprimit_texdef.coords[1][0] << " coords[1][1]:" << projection.m_brushprimit_texdef.coords[1][1] << " coords[1][2]:" << projection.m_brushprimit_texdef.coords[1][2] << "\n";
// globalOutputStream() << "width:" << width << " height" << height << "\n";
//globalOutputStream() << "identity2transformed: " << identity2transformed << "\n";
//globalOutputStream() << "plane.normal(): " << plane.normal() << "\n";
#if 1
#if 0
Vector3 normalTransformed( matrix4_transformed_direction( identity2transformed, plane.normal() ) );
#else //preserves scale in BP while scaling, but not shift
#else //preserves scale in BP while scaling, but not shift //fixes QNAN
Matrix4 maa( matrix4_affine_inverse( identity2transformed ) );
matrix4_transpose( maa );
Vector4 vec4 = matrix4_transformed_vector4( maa, Vector4( plane.normal(), 0 ) );
Vector3 normalTransformed = vector3_normalised( vector4_to_vector3( vec4 ) );
//Vector4 vec4 = matrix4_transformed_vector4( maa, Vector4( plane.normal(), 0 ) );
//Vector3 normalTransformed( vector3_normalised( vector4_to_vector3( vec4 ) ) );
Vector3 normalTransformed( vector3_normalised( matrix4_transformed_direction( maa, plane.normal() ) ) );
#endif
//globalOutputStream() << "normalTransformed: " << normalTransformed << "\n";
@ -1481,17 +1488,18 @@ void Texdef_transformLocked( TextureProjection& projection, std::size_t width, s
Matrix4 transformed2stTransformed;
Texdef_basisForNormal( projection, normalTransformed, transformed2stTransformed );
// globalOutputStream() << "transformed2stTransformed: " << transformed2stTransformed << "\n";
Matrix4 stTransformed2identity( matrix4_affine_inverse( matrix4_multiplied_by_matrix4( transformed2stTransformed, identity2transformed ) ) );
// globalOutputStream() << "stTransformed2identity: " << stTransformed2identity << "\n";
Vector3 originalProjectionAxis( vector4_to_vector3( matrix4_affine_inverse( identity2stIdentity ).z() ) );
Vector3 transformedProjectionAxis( vector4_to_vector3( stTransformed2identity.z() ) );
Matrix4 stIdentity2stOriginal;
Texdef_toTransform( projection, (float)width, (float)height, stIdentity2stOriginal );
// globalOutputStream() << "stIdentity2stOriginal: " << stIdentity2stOriginal << "\n";
Matrix4 identity2stOriginal( matrix4_multiplied_by_matrix4( stIdentity2stOriginal, identity2stIdentity ) );
// globalOutputStream() << "identity2stOriginal: " << identity2stOriginal << "\n";
//globalOutputStream() << "originalProj: " << originalProjectionAxis << "\n";
//globalOutputStream() << "transformedProj: " << transformedProjectionAxis << "\n";
double dot = vector3_dot( originalProjectionAxis, transformedProjectionAxis );
@ -1521,9 +1529,13 @@ void Texdef_transformLocked( TextureProjection& projection, std::size_t width, s
}
Matrix4 stTransformed2stOriginal = matrix4_multiplied_by_matrix4( identity2stOriginal, stTransformed2identity );
// globalOutputStream() << "stTransformed2stOriginal: " << stTransformed2stOriginal << "\n";
Texdef_fromTransform( projection, (float)width, (float)height, stTransformed2stOriginal );
// globalOutputStream() << "AP: scale[0]:" << projection.m_texdef.scale[0] << " scale[1]:" << projection.m_texdef.scale[1] << " shift[0]:" << projection.m_texdef.shift[0] << " shift[1]:" << projection.m_texdef.shift[1] << " rotate:" << projection.m_texdef.rotate << "\n";
// globalOutputStream() << "BP: coords[0][0]:" << projection.m_brushprimit_texdef.coords[0][0] << " coords[0][1]:" << projection.m_brushprimit_texdef.coords[0][1] << " coords[0][2]:" << projection.m_brushprimit_texdef.coords[0][2] << " coords[1][0]:" << projection.m_brushprimit_texdef.coords[1][0] << " coords[1][1]:" << projection.m_brushprimit_texdef.coords[1][1] << " coords[1][2]:" << projection.m_brushprimit_texdef.coords[1][2] << "\n";
Texdef_normalise( projection, (float)width, (float)height );
// globalOutputStream() << "AP norm: scale[0]:" << projection.m_texdef.scale[0] << " scale[1]:" << projection.m_texdef.scale[1] << " shift[0]:" << projection.m_texdef.shift[0] << " shift[1]:" << projection.m_texdef.shift[1] << " rotate:" << projection.m_texdef.rotate << "\n";
// globalOutputStream() << "BP norm: coords[0][0]:" << projection.m_brushprimit_texdef.coords[0][0] << " coords[0][1]:" << projection.m_brushprimit_texdef.coords[0][1] << " coords[0][2]:" << projection.m_brushprimit_texdef.coords[0][2] << " coords[1][0]:" << projection.m_brushprimit_texdef.coords[1][0] << " coords[1][1]:" << projection.m_brushprimit_texdef.coords[1][1] << " coords[1][2]:" << projection.m_brushprimit_texdef.coords[1][2] << "\n";
}
#if 1

View File

@ -133,12 +133,12 @@ struct layout_globals_t
int nState;
layout_globals_t() :
m_position( -1, -1, 640, 480 ),
m_position( -1, -1, 962, 480 ),
nXYHeight( 350 ),
nXYHeight( 377 ),
nXYWidth( 600 ),
nCamWidth( 300 ),
nCamHeight( 210 ),
nCamHeight( 230 ),
nState( 0 ){
}
};
@ -1900,6 +1900,8 @@ LatchedBool g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
LatchedBool g_Layout_enableFilterToolbar( true, "Filter Toolbar" );
LatchedBool g_Layout_SingleToolbar( true, "Single Scrollable Toolbar" );
GtkMenuItem* create_file_menu(){
@ -2954,6 +2956,17 @@ static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data
return TRUE;
}
gboolean toolbar_redirect_scroll( GtkWidget* widget, GdkEventScroll* event, gpointer user_data ){
//globalOutputStream() << "scroll\n";
if ( event->direction == GDK_SCROLL_UP ) {
event->direction = GDK_SCROLL_RIGHT;
}
else if ( event->direction == GDK_SCROLL_DOWN ) {
event->direction = GDK_SCROLL_LEFT;
}
return FALSE;
}
void MainFrame::Create(){
GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
@ -2999,31 +3012,65 @@ void MainFrame::Create(){
GtkMenuBar* main_menu = create_main_menu( CurrentStyle() );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_menu ), FALSE, FALSE, 0 );
if( g_Layout_enableMainToolbar.m_value ){
GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 );
}
if( g_Layout_SingleToolbar.m_value ){
if( g_Layout_enableMainToolbar.m_value || g_Layout_enablePluginToolbar.m_value || g_Layout_enableFilterToolbar.m_value ){
GtkWidget* scr_win = gtk_scrolled_window_new( NULL, NULL );
gtk_container_set_border_width( GTK_CONTAINER( scr_win ), 0 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr_win ), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER );
GtkWidget* scrollbar = gtk_scrolled_window_get_hscrollbar( GTK_SCROLLED_WINDOW( scr_win ) );
gtk_widget_set_size_request( scrollbar, 0, 0 );
//gtk_widget_set_child_visible( scrollbar, FALSE );
//gtk_container_set_border_width( GTK_CONTAINER( scrollbar ), 0 );
if ( g_Layout_enablePluginToolbar.m_value || g_Layout_enableFilterToolbar.m_value ){
GtkWidget* PFbox = gtk_hbox_new( FALSE, 3 );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( PFbox ), FALSE, FALSE, 0 );
gtk_widget_show( PFbox );
if ( g_Layout_enablePluginToolbar.m_value ){
GtkToolbar* plugin_toolbar = create_plugin_toolbar();
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr_win ), GTK_SHADOW_NONE );
gtk_box_pack_start( GTK_BOX( vbox ), scr_win, FALSE, FALSE, 0 );
gtk_widget_show( scr_win );
g_signal_connect( G_OBJECT( scr_win ), "scroll_event", G_CALLBACK( toolbar_redirect_scroll ), 0 );
GtkWidget* hbox = gtk_hbox_new( FALSE, 3 );
gtk_widget_show( hbox );
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scr_win ), hbox );
if( g_Layout_enableMainToolbar.m_value ){
GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() );
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( main_toolbar ), TRUE, TRUE, 0 );
}
if ( g_Layout_enableFilterToolbar.m_value ){
gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 );
GtkToolbar* filter_toolbar = create_filter_toolbar();
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( filter_toolbar ), TRUE, TRUE, 0 );
}
else{
gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( plugin_toolbar ), TRUE, TRUE, 0 );
if ( g_Layout_enablePluginToolbar.m_value ){
GtkToolbar* plugin_toolbar = create_plugin_toolbar();
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( plugin_toolbar ), TRUE, TRUE, 0 );
}
}
if ( g_Layout_enableFilterToolbar.m_value ){
GtkToolbar* filter_toolbar = create_filter_toolbar();
gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( filter_toolbar ), TRUE, TRUE, 0 );
}
else{
if( g_Layout_enableMainToolbar.m_value ){
GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 );
}
if ( g_Layout_enablePluginToolbar.m_value || g_Layout_enableFilterToolbar.m_value ){
GtkWidget* hbox = gtk_hbox_new( FALSE, 3 );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 );
gtk_widget_show( hbox );
if ( g_Layout_enablePluginToolbar.m_value ){
GtkToolbar* plugin_toolbar = create_plugin_toolbar();
if ( g_Layout_enableFilterToolbar.m_value ){
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 );
}
else{
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( plugin_toolbar ), TRUE, TRUE, 0 );
}
}
if ( g_Layout_enableFilterToolbar.m_value ){
GtkToolbar* filter_toolbar = create_filter_toolbar();
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( filter_toolbar ), TRUE, TRUE, 0 );
}
}
}
/*GtkToolbar* plugin_toolbar = create_plugin_toolbar();
if ( !g_Layout_enablePluginToolbar.m_value ) {
gtk_widget_hide( GTK_WIDGET( plugin_toolbar ) );
@ -3465,6 +3512,11 @@ void Layout_constructPreferences( PreferencesPage& page ){
LatchedBoolImportCaller( g_Layout_enableFilterToolbar ),
BoolExportCaller( g_Layout_enableFilterToolbar.m_latched )
);
page.appendCheckBox(
"", "Single Scrollable Toolbar",
LatchedBoolImportCaller( g_Layout_SingleToolbar ),
BoolExportCaller( g_Layout_SingleToolbar.m_latched )
);
}
void Layout_constructPage( PreferenceGroup& group ){
@ -3621,6 +3673,7 @@ void MainFrame_Construct(){
GlobalPreferenceSystem().registerPreference( "PatchToolBar", BoolImportStringCaller( g_Layout_enablePatchToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) );
GlobalPreferenceSystem().registerPreference( "PluginToolBar", BoolImportStringCaller( g_Layout_enablePluginToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) );
GlobalPreferenceSystem().registerPreference( "FilterToolBar", BoolImportStringCaller( g_Layout_enableFilterToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableFilterToolbar.m_latched ) );
GlobalPreferenceSystem().registerPreference( "SingleToolBar", BoolImportStringCaller( g_Layout_SingleToolbar.m_latched ), BoolExportStringCaller( g_Layout_SingleToolbar.m_latched ) );
GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", IntImportStringCaller( g_Layout_viewStyle.m_latched ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) );
GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) );
GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) );
@ -3670,6 +3723,7 @@ void MainFrame_Construct(){
g_Layout_enablePatchToolbar.useLatched();
g_Layout_enablePluginToolbar.useLatched();
g_Layout_enableFilterToolbar.useLatched();
g_Layout_SingleToolbar.useLatched();
Layout_registerPreferencesPage();
Paths_registerPreferencesPage();

View File

@ -1246,7 +1246,7 @@ void Patch::constructPlane( const AABB& aabb, int axis, std::size_t width, std::
Vector3 vStart;
vStart[x] = aabb.origin[x] - aabb.extents[x];
vStart[y] = aabb.origin[y] - aabb.extents[y];
vStart[z] = aabb.origin[z];
vStart[z] = aabb.origin[z] + aabb.extents[z];
float xAdj = fabsf( ( vStart[x] - ( aabb.origin[x] + aabb.extents[x] ) ) / (float)( m_width - 1 ) );
float yAdj = fabsf( ( vStart[y] - ( aabb.origin[y] + aabb.extents[y] ) ) / (float)( m_height - 1 ) );
@ -1266,8 +1266,6 @@ void Patch::constructPlane( const AABB& aabb, int axis, std::size_t width, std::
}
vTmp[y] += yAdj;
}
NaturalTexture();
}
void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std::size_t width, std::size_t height ){