unify angles key reading

This commit is contained in:
Garux 2021-11-08 21:39:38 +03:00
parent 484c63ae4a
commit 76017a8ce3
5 changed files with 22 additions and 22 deletions

View File

@ -181,7 +181,7 @@ textures/skies/xtoxicsky_dm9
<h2 id="sort">sort value</h2>
<p>Use this keyword to fine-tune the depth sorting of shaders as they are compared against other shaders in the game world. The basic concept is that if there is a question or a problem with shaders drawing in the wrong order against each other, this allows the designer to create a hierarchy of which shader draws in what order.</p>
<p>The default behavior is to put all blended shaders in sort "additive" and all other shaders in sort "opaque", so you only need to specify this when you are trying to work around a sorting problem with multiple transparent surfaces in a scene.</p>
<p>The default behavior is to put all blended shaders in sort 9 and all other shaders in sort "opaque", so you only need to specify this when you are trying to work around a sorting problem with multiple transparent surfaces in a scene.</p>
<p>The value here can be either a numerical value or one of the keywords in the following list (listed in order of ascending priority):</p>
<dl>
<dt>portal (1)</dt><dd>This surface is a portal, it draws over every other shader seen inside the portal, but before anything in the main view. Default for shaders marked as portal.</dd>

View File

@ -179,6 +179,11 @@ inline bool VectorIsOnAxis( const Vector3& v ){
return zeroComponentCount > 1; // The zero vector will be on axis.
}
/* (pitch yaw roll) -> (roll pitch yaw) */
inline Vector3 angles_pyr2rpy( const Vector3& angles ){
return Vector3( angles.z(), angles.x(), angles.y() );
}
/*
=====================
PlaneFromPoints

View File

@ -1059,11 +1059,11 @@ static void PopulateTraceNodes(){
for ( std::size_t i = 1; i < entities.size(); ++i )
{
/* get entity */
entity_t *e = &entities[ i ];
const entity_t& e = entities[ i ];
/* get shadow flags */
int castShadows = ENTITY_CAST_SHADOWS;
GetEntityShadowFlags( e, NULL, &castShadows, NULL );
GetEntityShadowFlags( &e, NULL, &castShadows, NULL );
/* early out? */
if ( !castShadows ) {
@ -1071,19 +1071,18 @@ static void PopulateTraceNodes(){
}
/* get entity origin */
const Vector3 origin( e->vectorForKey( "origin" ) );
const Vector3 origin( e.vectorForKey( "origin" ) );
/* get scale */
Vector3 scale( 1 );
if( !e->read_keyvalue( scale, "modelscale_vec" ) )
if( e->read_keyvalue( scale[0], "modelscale" ) )
if( !e.read_keyvalue( scale, "modelscale_vec" ) )
if( e.read_keyvalue( scale[0], "modelscale" ) )
scale[1] = scale[2] = scale[0];
/* get "angle" (yaw) or "angles" (pitch yaw roll), store as (roll pitch yaw) */
Vector3 angles( 0 );
if ( !e->read_keyvalue( value, "angles" ) ||
3 != sscanf( value, "%f %f %f", &angles[ 1 ], &angles[ 2 ], &angles[ 0 ] ) )
e->read_keyvalue( angles[ 2 ], "angle" );
if ( e.read_keyvalue( angles, "angles" ) || e.read_keyvalue( angles.y(), "angle" ) )
angles = angles_pyr2rpy( angles );
/* set transform matrix (thanks spog) */
transform = g_matrix4_identity;
@ -1095,7 +1094,7 @@ static void PopulateTraceNodes(){
//% m4x4_transpose( transform );
/* get model */
value = e->valueForKey( "model" );
value = e.valueForKey( "model" );
/* switch on model type */
switch ( value[ 0 ] )
@ -1115,12 +1114,12 @@ static void PopulateTraceNodes(){
/* external model */
default:
PopulateWithPicoModel( castShadows, LoadModelWalker( value, e->intForKey( "_frame", "frame" ) ), transform );
PopulateWithPicoModel( castShadows, LoadModelWalker( value, e.intForKey( "_frame", "frame" ) ), transform );
continue;
}
/* get model2 */
value = e->valueForKey( "model2" );
value = e.valueForKey( "model2" );
/* switch on model type */
switch ( value[ 0 ] )
@ -1140,7 +1139,7 @@ static void PopulateTraceNodes(){
/* external model */
default:
PopulateWithPicoModel( castShadows, LoadModelWalker( value, e->intForKey( "_frame2" ) ), transform );
PopulateWithPicoModel( castShadows, LoadModelWalker( value, e.intForKey( "_frame2" ) ), transform );
continue;
}
}

View File

@ -1327,11 +1327,9 @@ void AddTriangleModels( entity_t& eparent ){
scale[1] = scale[2] = scale[0];
/* get "angle" (yaw) or "angles" (pitch yaw roll), store as (roll pitch yaw) */
const char *value;
Vector3 angles( 0 );
if ( !e.read_keyvalue( value, "angles" ) ||
3 != sscanf( value, "%f %f %f", &angles[ 1 ], &angles[ 2 ], &angles[ 0 ] ) )
e.read_keyvalue( angles[ 2 ], "angle" );
if ( e.read_keyvalue( angles, "angles" ) || e.read_keyvalue( angles.y(), "angle" ) )
angles = angles_pyr2rpy( angles );
/* set transform matrix (thanks spog) */
Matrix4 transform( g_matrix4_identity );
@ -1378,7 +1376,7 @@ void AddTriangleModels( entity_t& eparent ){
/* ydnar: cel shader support */
shaderInfo_t *celShader;
if( e.read_keyvalue( value, "_celshader" ) ||
if( const char *value; e.read_keyvalue( value, "_celshader" ) ||
entities[ 0 ].read_keyvalue( value, "_celshader" ) ){
celShader = ShaderInfoForShader( String64()( "textures/", value ) );
}

View File

@ -542,7 +542,6 @@ static bool PlaceOccupant( node_t *headnode, const Vector3& origin, const entity
EFloodEntities FloodEntities( tree_t& tree ){
bool r, inside, skybox;
const char *value;
Sys_FPrintf( SYS_VRB, "--- FloodEntities ---\n" );
@ -580,9 +579,8 @@ EFloodEntities FloodEntities( tree_t& tree ){
/* get "angle" (yaw) or "angles" (pitch yaw roll), store as (roll pitch yaw) */
Vector3 angles( 0 );
if ( !e.read_keyvalue( value, "angles" ) ||
3 != sscanf( value, "%f %f %f", &angles[ 1 ], &angles[ 2 ], &angles[ 0 ] ) )
e.read_keyvalue( angles[ 2 ], "angle" );
if ( e.read_keyvalue( angles, "angles" ) || e.read_keyvalue( angles.y(), "angle" ) )
angles = angles_pyr2rpy( angles );
/* set transform matrix (thanks spog) */
skyboxTransform = g_matrix4_identity;