misc...
	* fix scaling for doom3 brush format
	* Pointfile function: try to also load .pts leak line file (q1), if .lin isn't found
	* snap transform origin for flip commands
	* change light intensity save format from %f to %g to prevent .99999 on transforms
	* support 'stupid quake bug' (invert pitch in angles)(generic and miscmodel ents)(cfg: entities="quake" in .game)
	* clipper: place 1st and 2nd points far, 3rd near to ease 3 points clipping
This commit is contained in:
Garux 2017-08-02 09:44:51 +03:00
parent 0139fa9de6
commit 492f00b729
15 changed files with 92 additions and 20 deletions

View File

@ -602,6 +602,9 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){
else if ( gtk_toggle_button_get_active( (GtkToggleButton*)spline ) ) {
type = 2;
}
else{
break;
}
// Add the target
GetCurrentCam()->GetCam()->addTarget( str, static_cast<idCameraPosition::positionType>( type ) );

View File

@ -120,8 +120,8 @@ virtual void addSelectionChangeCallback( const SelectionChangeHandler& handler )
virtual void NudgeManipulator( const Vector3& nudge, const Vector3& view ) = 0;
virtual void translateSelected( const Vector3& translation ) = 0;
virtual void rotateSelected( const Quaternion& rotation, bool snapOrigin ) = 0;
virtual void scaleSelected( const Vector3& scaling ) = 0;
virtual void rotateSelected( const Quaternion& rotation, bool snapOrigin = false ) = 0;
virtual void scaleSelected( const Vector3& scaling, bool snapOrigin = false ) = 0;
virtual void pivotChanged() const = 0;
virtual void setCustomPivotOrigin( Vector3& point ) const = 0;

View File

@ -30,6 +30,8 @@
#include "angle.h"
#include "entity.h"
const Vector3 ANGLESKEY_IDENTITY = Vector3( 0, 0, 0 );
inline void default_angles( Vector3& angles ){
@ -57,7 +59,7 @@ inline void read_angles( Vector3& angles, const char* value ){
}
else
{
angles = Vector3( angles[2], angles[0], angles[1] );
angles = Vector3( angles[2], g_stupidQuakeBug? -angles[0] : angles[0], angles[1] );
normalise_angles( angles );
}
}
@ -71,14 +73,14 @@ inline void write_angles( const Vector3& angles, Entity* entity ){
else
{
if ( angles[0] == 0 && angles[1] == 0 ) {
float yaw = angles[2];
const float yaw = angles[2];
entity->setKeyValue( "angles", "" );
write_angle( yaw, entity );
}
else
{
char value[64];
sprintf( value, "%g %g %g", angles[1], angles[2], angles[0] );
sprintf( value, "%g %g %g", g_stupidQuakeBug? -angles[1] : angles[1], angles[2], angles[0] );
entity->setKeyValue( "angle", "" );
entity->setKeyValue( "angles", value );
}

View File

@ -120,6 +120,9 @@ bool g_showTargetNames = false;
bool g_showAngles = true;
bool g_lightRadii = true;
bool g_stupidQuakeBug = false;
class ConnectEntities
{
public:
@ -400,6 +403,10 @@ void Entity_Construct( EGameType gameType ){
Static<KeyIsName>::instance().m_nameKey = "targetname";
}
if( g_gameType == eGameTypeQuake1 ){
g_stupidQuakeBug = true;
}
GlobalPreferenceSystem().registerPreference( "SI_ShowNames", BoolImportStringCaller( g_showNames ), BoolExportStringCaller( g_showNames ) );
GlobalPreferenceSystem().registerPreference( "SI_ShowBboxes", BoolImportStringCaller( g_showBboxes ), BoolExportStringCaller( g_showBboxes ) );
GlobalPreferenceSystem().registerPreference( "SI_ShowNamesDist", IntImportStringCaller( g_showNamesDist ), IntExportStringCaller( g_showNamesDist ) );

View File

@ -28,6 +28,7 @@ EntityCreator& GetEntityCreator();
enum EGameType
{
eGameTypeQuake3,
eGameTypeQuake1,
eGameTypeRTCW,
eGameTypeDoom3,
};
@ -46,4 +47,6 @@ extern bool g_showTargetNames;
extern bool g_showAngles;
extern bool g_lightRadii;
extern bool g_stupidQuakeBug;
#endif

View File

@ -673,7 +673,7 @@ void light_draw( const AABB& aabb_light, RenderStateFlags state ){
inline void write_intensity( const float intensity, Entity* entity ){
char value[64];
sprintf( value, "%f", intensity );
sprintf( value, "%g", intensity );
//primaryIntensity
if( !string_empty( entity->getKeyValue( "_light" ) ) ){

View File

@ -86,6 +86,33 @@ typedef SingletonModule<EntityQ3API, EntityDependencies> EntityQ3Module;
EntityQ3Module g_EntityQ3Module;
class EntityQ1API : public TypeSystemRef
{
EntityCreator* m_entityq1;
public:
typedef EntityCreator Type;
STRING_CONSTANT( Name, "quake" );
EntityQ1API(){
Entity_Construct( eGameTypeQuake1);
m_entityq1 = &GetEntityCreator();
GlobalReferenceCache().setEntityCreator( *m_entityq1 );
}
~EntityQ1API(){
Entity_Destroy();
}
EntityCreator* getTable(){
return m_entityq1;
}
};
typedef SingletonModule<EntityQ1API, EntityDependencies> EntityQ1Module;
EntityQ1Module g_EntityQ1Module;
class EntityWolfAPI : public TypeSystemRef
{
EntityCreator* m_entitywolf;
@ -144,6 +171,7 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server
initialiseModule( server );
g_EntityQ3Module.selfRegister();
g_EntityQ1Module.selfRegister();
g_EntityWolfModule.selfRegister();
g_EntityDoom3Module.selfRegister();
Doom3ModelSkinCacheModule_selfRegister( server );

View File

@ -632,8 +632,12 @@ inline Plane3 Plane3_applyTranslation( const Plane3& plane, const Vector3& trans
}
inline Plane3 Plane3_applyTransform( const Plane3& plane, const Matrix4& matrix ){
Plane3 tmp( plane3_transformed( Plane3( plane.normal(), -plane.dist() ), matrix ) );
return Plane3( tmp.normal(), -tmp.dist() );
//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 ) ) ) );
}
class FacePlane

View File

@ -1305,8 +1305,14 @@ void Texdef_transformLocked( TextureProjection& projection, std::size_t width, s
//globalOutputStream() << "identity2transformed: " << identity2transformed << "\n";
//globalOutputStream() << "plane.normal(): " << plane.normal() << "\n";
#if 1
Vector3 normalTransformed( matrix4_transformed_direction( identity2transformed, plane.normal() ) );
#else //preserves scale in BP while scaling, but not shift
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 ) );
#endif
//globalOutputStream() << "normalTransformed: " << normalTransformed << "\n";

View File

@ -272,7 +272,14 @@ void Pointfile_Parse( CPointfile& pointfile ){
size = LoadFile( name.c_str(), (void**)&data );
if ( size == -1 ) {
globalErrorStream() << "Pointfile " << name.c_str() << " not found\n";
return;
/* try .pts (q1) */
name.clear();
name << StringRange( mapname, path_get_filename_base_end( mapname ) ) << ".pts";
size = LoadFile( name.c_str(), (void**)&data );
if ( size == -1 ) {
globalErrorStream() << "Pointfile " << name.c_str() << " not found\n";
return;
}
}
// store a pointer

View File

@ -548,7 +548,7 @@ void Select_GetMid( Vector3& mid ){
void Select_FlipAxis( int axis ){
Vector3 flip( 1, 1, 1 );
flip[axis] = -1;
GlobalSelectionSystem().scaleSelected( flip );
GlobalSelectionSystem().scaleSelected( flip, true );
}
@ -652,13 +652,13 @@ void Select_RotateAxis( int axis, float deg ){
switch ( axis )
{
case 0:
GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_x_degrees( deg ) ), false );
GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_x_degrees( deg ) ) );
break;
case 1:
GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_y_degrees( deg ) ), false );
GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_y_degrees( deg ) ) );
break;
case 2:
GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_z_degrees( deg ) ), false );
GlobalSelectionSystem().rotateSelected( quaternion_for_matrix4_rotation( matrix4_rotation_for_z_degrees( deg ) ) );
break;
}
}
@ -1190,7 +1190,7 @@ static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog )
command << "rotateSelectedEulerXYZ -x " << eulerXYZ[0] << " -y " << eulerXYZ[1] << " -z " << eulerXYZ[2];
UndoableCommand undo( command.c_str() );
GlobalSelectionSystem().rotateSelected( quaternion_for_euler_xyz_degrees( eulerXYZ ), false );
GlobalSelectionSystem().rotateSelected( quaternion_for_euler_xyz_degrees( eulerXYZ ) );
return TRUE;
}

View File

@ -3459,7 +3459,7 @@ void outputScale( TextOutputStream& ostream ){
ostream << " -scale " << m_scale.x() << " " << m_scale.y() << " " << m_scale.z();
}
void rotateSelected( const Quaternion& rotation, bool snapOrigin ){
void rotateSelected( const Quaternion& rotation, bool snapOrigin = false ){
if( snapOrigin && !m_pivotIsCustom ){
m_pivot2world.tx() = float_snapped( m_pivot2world.tx(), GetSnapGridSize() );
m_pivot2world.ty() = float_snapped( m_pivot2world.ty(), GetSnapGridSize() );
@ -3474,7 +3474,12 @@ void translateSelected( const Vector3& translation ){
translate( translation );
freezeTransforms();
}
void scaleSelected( const Vector3& scaling ){
void scaleSelected( const Vector3& scaling, bool snapOrigin = false ){
if( snapOrigin && !m_pivotIsCustom ){
m_pivot2world.tx() = float_snapped( m_pivot2world.tx(), GetSnapGridSize() );
m_pivot2world.ty() = float_snapped( m_pivot2world.ty(), GetSnapGridSize() );
m_pivot2world.tz() = float_snapped( m_pivot2world.tz(), GetSnapGridSize() );
}
startMove();
scale( scaling );
freezeTransforms();

View File

@ -36,6 +36,7 @@ bool open_url( const char* url ){
#include <stdlib.h>
bool open_url( const char* url ){
// \todo FIXME: the way we open URLs on *nix should be improved. A script is good (see how I do on RTCW)
//Fedora 25: Help > Manual leads to "sh: firefox: command not found" error on terminal, while xdg-open http://some/url/ works just fine (and opens up the URL in the web browser)
char command[2 * PATH_MAX];
snprintf( command, sizeof( command ),
"firefox -remote \"openURL(%s,new-window)\" || firefox \"%s\" &", url, url );

View File

@ -970,11 +970,16 @@ void XYWnd::DropClipPoint( int pointx, int pointy ){
XY_ToPoint( pointx, pointy, point );
Vector3 mid;
Select_GetMid( mid );
Vector3 mins, maxs;
Select_GetBounds( mins, maxs );
g_clip_viewtype = GetViewType();
const int nDim = ( g_clip_viewtype == YZ ) ? 0 : ( ( g_clip_viewtype == XZ ) ? 1 : 2 );
point[nDim] = mid[nDim];
if( g_Clip2.Set() && !g_Clip3.Set() ){
point[nDim] = maxs[nDim];
}
else{
point[nDim] = mins[nDim];
}
vector3_snap( point, GetSnapGridSize() );
NewClipPoint( point );
}

View File

@ -1382,6 +1382,7 @@ void StitchSurfaceLightmaps( void ){
/* add luxel */
//% VectorSet( luxel2, 255, 0, 255 );
numLuxels++;
VectorAdd( average, luxel2, average );
totalColor += luxel2[ 3 ];
}