Пример #1
0
X42_EXPORT affine_t* X42_CALL x42_GetAnimTagMatrices( void *out_buffer, const x42data_t *x42,
	const affine_t *boneMats, x42opts_t *opts )
{
	uint i;

	affine_t * RESTRICT ret;

	const affine_t * RESTRICT bm;

	REF_PARAM( opts );

#ifndef LIBX42_NO_PARAM_VALIDATION
	demand_rn( out_buffer != NULL, X42_ERR_BADPTR, "out_buffer is NULL" );
	demand_rn( boneMats != NULL, X42_ERR_BADPTR, "boneMats is NULL" );
	demand_rn( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" );
	demand_rn( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" );
#endif

	bm = boneMats;
	ret = (affine_t*)out_buffer;

	for( i = 0; i < x42->header.numTags; i++ )
		compute_anim_tag_matrix( ret + i, x42, bm, x42->tags + i );

	return ret;
}
Пример #2
0
bool opt_copy_stream_to_stream( x42memStream_t *dest, x42memStream_t *src,
	size_t elemSize, uint numElems, x42opts_t *opts )
{
	REF_PARAM( opts );
	
	if( (opts->caps & OPT_SSE2) &&
		elemSize <= sizeof( __m128 ) &&
		stream_is_aligned( src ) && stream_pad_ok( src, elemSize ) &&
		stream_is_aligned( dest ) && stream_pad_ok( dest, elemSize ) )
	{ 
		uint i; 

		size_t is = src->stride; 
		size_t os = dest->stride; 

		const __m128i * RESTRICT pi = (__m128i*)src->pStreamZero; 
		__m128i * RESTRICT po = (__m128i*)dest->pStreamZero; 

		for( i = 0; i < numElems; i++ ) 
		{ 
			__m128i v = _mm_load_si128( pi ); 
			_mm_stream_si128( po, v ); 

			pi = (__m128i*)((byte*)pi + is); 
			po = (__m128i*)((byte*)po + os); 
		} 

		_mm_sfence(); 

		return true;
	}
Пример #3
0
X42_EXPORT bool X42_CALL x42_ApplyBoneOffsets( x42animLerp_t *lerp, const x42data_t *x42,
	const x42boneOffset_t *offsets, uint numOffsets, x42opts_t *opts )
{
	uint i, j;

	REF_PARAM( opts );

#ifndef LIBX42_NO_PARAM_VALIDATION
	demand_rf( lerp != NULL, X42_ERR_BADPTR, "lerp is NULL" );
	demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" );
	demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" );
	demand_rf( offsets != NULL, X42_ERR_BADPTR, "offsets is NULL" );
#endif

	for( i = 0; i < numOffsets; i++ )
	{
		for( j = 0; j < x42->header.numBones; j++ )
		{
			if( x42name_eq2( x42, x42->bones[j].name, offsets[i].boneName ) )
				break;
		}

		if( j == x42->header.numBones )
			continue;

		vec3_add( lerp->p[j], lerp->p[j], offsets[i].pos_offset );
		vec3_add( lerp->s[j], lerp->s[j], offsets[i].scale_offset );

		quat_mul( lerp->r[j], offsets[i].rot_offset, lerp->r[j] );
	}

	return true;
}
Пример #4
0
X42_EXPORT bool X42_CALL x42_GetAnimTagMatrix2( affine_t *out_buffer, const x42data_t *x42,
	const affine_t *boneMats, const char *tagName, x42opts_t *opts )
{
	uint i;

	REF_PARAM( opts );

#ifndef LIBX42_NO_PARAM_VALIDATION
	demand_rf( out_buffer != NULL, X42_ERR_BADPTR, "out_buffer is NULL" );
	demand_rf( boneMats != NULL, X42_ERR_BADPTR, "boneMats is NULL" );
	demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" );
	demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" );
	demand_rf( tagName != NULL, X42_ERR_BADPTR, "tagName is NULL" );
#endif

	for( i = 0; i < x42->header.numTags; i++ )
	{
		if( x42name_eq2( x42, x42->tags[i].name, tagName ) )
			break;
	}

	if( i == x42->header.numTags )
		return false;

	compute_anim_tag_matrix( out_buffer, x42, boneMats, x42->tags + i );

	return true;
}
Пример #5
0
	std::string 
	_nimble_exception::to_string(
		__in_opt bool verbose
		)
	{
		std::stringstream result;

		SERIALIZE_CALL_RECUR(m_lock);

		result << what();

#ifndef NDEBUG
		if(verbose) {
			SET_TERM_ATTRIB(result, 1, COL_FORE_YELLOW);
			result << " (";

			if(!m_source.empty()) {
				result << m_source << ":";
			}

			result << m_line << ") ";
			CLEAR_TERM_ATTRIB(result);
		}
#else
		REF_PARAM(verbose);
#endif

		return CHK_STR(result.str());
	}
Пример #6
0
X42_EXPORT bool X42_CALL x42_GetAnimTagMatrix( affine_t *out_buffer, const x42data_t *x42,
	const affine_t *boneMats, uint tagIndex, x42opts_t *opts )
{
	REF_PARAM( opts );

#ifndef LIBX42_NO_PARAM_VALIDATION
	demand_rf( out_buffer != NULL, X42_ERR_BADPTR, "out_buffer is NULL" );
	demand_rf( boneMats != NULL, X42_ERR_BADPTR, "boneMats is NULL" );
	demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" );
	demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" );
	demand_rf( tagIndex < x42->header.numTags, X42_ERR_BADPARAMS, "invalid tag index" );
#endif

	compute_anim_tag_matrix( out_buffer, x42, boneMats, x42->tags + tagIndex );

	return true;
}
Пример #7
0
static BOOL CALLBACK GLW_GetMonitorDisplayModes( HMONITOR mon, HDC dc, LPRECT rc, LPARAM userData )
{
	int i;
	DEVMODE mode;
	MONITORINFOEX info;
	int gl_level;

	REF_PARAM( rc );
	REF_PARAM( userData );

	info.cbSize = sizeof( info );
	GetMonitorInfo( mon, (LPMONITORINFO)&info );

	gl_level = 3;//GLW_GetDisplayLevel( dc );

	sql_bindtext( &com_db, 1, info.szDevice );
	sql_bindint( &com_db, 2, info.rcMonitor.left );
	sql_bindint( &com_db, 3, info.rcMonitor.top );
	sql_bindint( &com_db, 4, info.rcMonitor.right - info.rcMonitor.left );
	sql_bindint( &com_db, 5, info.rcMonitor.bottom - info.rcMonitor.top );
	sql_bindint( &com_db, 6, gl_level );
	sql_step( &com_db );

	mode.dmSize = sizeof( mode );
	mode.dmDriverExtra = 0;
	for( i = 0; EnumDisplaySettingsEx( info.szDevice, i, &mode, 0 ) != 0; i++ )
	{
		int id;

		if( mode.dmBitsPerPel < 16 )
			continue;

		if( mode.dmPelsWidth < 640 || mode.dmPelsHeight < 480 )
			continue;

		sql_prepare( &com_db, "UPDATE OR INSERT fsmodes SET id=#,w=?1,h=?2,dev_name=?3 SEARCH dev_name ?3 WHERE w=?1 AND h=?2" );
		sql_bindint( &com_db, 1, (int)mode.dmPelsWidth );
		sql_bindint( &com_db, 2, (int)mode.dmPelsHeight );
		sql_bindtext( &com_db, 3, info.szDevice );
		sql_step( &com_db );
		sql_done( &com_db );

		//get the id of what we just added

		sql_prepare( &com_db, "SELECT id FROM fsmodes SEARCH dev_name ?3 WHERE w=?1 AND h=?2" );
		sql_bindint( &com_db, 1, (int)mode.dmPelsWidth );
		sql_bindint( &com_db, 2, (int)mode.dmPelsHeight );
		sql_bindtext( &com_db, 3, info.szDevice );
		sql_step( &com_db );
		id = sql_columnasint( &com_db, 0 );
		sql_done( &com_db );

		//and insert the other info into the other table

		sql_prepare( &com_db, "UPDATE OR INSERT fsmodes_ext SET id=?1,hz=?2,bpp=?3 SEARCH id ?1 WHERE hz=?2 AND bpp=?3" );
		sql_bindint( &com_db, 1, id );
		sql_bindint( &com_db, 2, (int)mode.dmDisplayFrequency );
		sql_bindint( &com_db, 3, (int)mode.dmBitsPerPel );
		sql_step( &com_db );
		sql_done( &com_db );
	}

	return TRUE;
}
Пример #8
0
X42_EXPORT bool X42_CALL x42_LerpAnims( x42animLerp_t *lerp,
	const x42data_t *x42, const x42animFrames_t *anim, x42opts_t *opts )
{
	uint i, j;
	
	const vec3_t * RESTRICT pv;
	const vec3_t * RESTRICT sv;
	const quat_t * RESTRICT rv;

	vec3_t * RESTRICT po;
	vec3_t * RESTRICT so;
	quat_t * RESTRICT ro;

	REF_PARAM( opts );

#ifndef LIBX42_NO_PARAM_VALIDATION
	demand_rf( lerp != NULL, X42_ERR_BADPTR, "lerp is NULL" );
	demand_rf( anim != NULL, X42_ERR_BADPTR, "anim is NULL" );
	demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" );
	demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" );
#endif

	pv = x42->posValues;
	sv = x42->scaleValues;
	rv = x42->rotValues;

	po = lerp->p;
	so = lerp->s;
	ro = lerp->r;

	for( i = 0; i < x42->header.numAnimGroups; i++ )
	{
		const x42ksBoneEntry_t * RESTRICT p;

		uint beginBone = x42->animGroups[i].beginBone;
		uint endBone = x42->animGroups[i].endBone;

		float target = anim->frames[i].targetFrame;

		for( j = beginBone; j < endBone; j++ )
		{
			p = anim->kpairs[j][X42_KT_POSITION];

			if( p[0].value == p[1].value )
				vec3_cpy( po[j], pv[p[0].value] );
			else
			{
				float s = (float)(int)p[0].frame;
				float e = (float)(int)p[1].frame;

				float t = (target - s) / (e - s);

				vec3_lerp( po[j], pv[p[0].value], pv[p[1].value], t );
			}
		}

		for( j = beginBone; j < endBone; j++ )
		{
			p = anim->kpairs[j][X42_KT_SCALE];

			if( p[0].value == p[1].value )
				vec3_cpy( so[j], sv[p[0].value] );
			else
			{
				float s = (float)(int)p[0].frame;
				float e = (float)(int)p[1].frame;

				float t = (target - s) / (e - s);

				vec3_lerp( so[j], sv[p[0].value], sv[p[1].value], t );
			}
		}

		for( j = beginBone; j < endBone; j++ )
		{
			p = anim->kpairs[j][X42_KT_ROTATION];

			if( p[0].value == p[1].value )
				quat_cpy( ro[j], rv[p[0].value] );
			else
			{
				float s = (float)(int)p[0].frame;
				float e = (float)(int)p[1].frame;

				float t = (target - s) / (e - s);

				quat_interp( ro[j], rv[p[0].value], rv[p[1].value], t );
			}
		}
	}

	return true;
}
Пример #9
0
X42_EXPORT affine_t* X42_CALL x42_GetAnimBoneMatrices( void *out_buffer, const x42data_t *x42,
	const x42animLerp_t *lerp, x42opts_t *opts )
{
	uint i;

	affine_t * RESTRICT ret;

	const vec3_t * RESTRICT pv;
	const vec3_t * RESTRICT sv;
	const quat_t * RESTRICT rv;

	REF_PARAM( opts );

#ifndef LIBX42_NO_PARAM_VALIDATION
	demand_rn( out_buffer != NULL, X42_ERR_BADPTR, "out_buffer is NULL" );
	demand_rn( lerp != NULL, X42_ERR_BADPTR, "lerp is NULL" );
	demand_rn( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" );
	demand_rn( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" );
#endif

	pv = lerp->p;
	sv = lerp->s;
	rv = lerp->r;

	ret = (affine_t*)out_buffer;

	for( i = 0; i < x42->header.numBones; i++ )
	{
		affine_t * RESTRICT o = ret + i;

		const x42bone_t * RESTRICT b = x42->bones + i;

		if( b->parentIdx != X42_MODEL_BONE && (b->flags & X42_BF_USE_INV_PARENT_SCALE) )
		{
			vec3_t ips;
			affine_t rs;

			quat_to_affine( &rs, rv[i] );

			vec3_scale( rs.c[0], rs.c[0], sv[i][0] );
			vec3_scale( rs.c[1], rs.c[1], sv[i][1] );
			vec3_scale( rs.c[2], rs.c[2], sv[i][2] );

			ips[0] = 1.0F / sv[b->parentIdx][0];
			ips[1] = 1.0F / sv[b->parentIdx][1];
			ips[2] = 1.0F / sv[b->parentIdx][2];

			vec3_mul( o->c[0], rs.c[0], ips );
			vec3_mul( o->c[1], rs.c[1], ips );
			vec3_mul( o->c[2], rs.c[2], ips );
		}
		else
		{
			quat_to_affine( o, rv[i] );

			vec3_scale( o->c[0], o->c[0], sv[i][0] );
			vec3_scale( o->c[1], o->c[1], sv[i][1] );
			vec3_scale( o->c[2], o->c[2], sv[i][2] );
		}

		vec3_cpy( o->c[3], pv[i] );
	}

	for( i = 0; i < x42->header.numBones; i++ )
	{
		const x42bone_t * RESTRICT b = x42->bones + i;

		if( b->parentIdx != X42_MODEL_BONE )
			affine_mul( ret + i, ret + b->parentIdx, ret + i );
		else if( x42->header.runFlags & X42_RF_ROOT_MATRIX )
			affine_mul( ret + i, &x42->rootMatrix, ret + i );		
	}

	return ret;
}
Пример #10
0
X42_EXPORT x42animLerp_t* X42_CALL x42_BlendAnimations( void *out_buffer, const x42data_t *x42,
	const x42animLerp_t *lerp0, const x42animLerp_t *lerp1, const float *blendValues, x42opts_t *opts )
{
	uint i, j;

	x42animLerp_t *ret;

	const vec3_t * RESTRICT pv0, * RESTRICT pv1;
	const vec3_t * RESTRICT sv0, * RESTRICT sv1;
	const quat_t * RESTRICT rv0, * RESTRICT rv1;

	vec3_t * RESTRICT po;
	vec3_t * RESTRICT so;
	quat_t * RESTRICT ro;

	REF_PARAM( opts );

#ifndef LIBX42_NO_PARAM_VALIDATION
	demand_rn( out_buffer != NULL, X42_ERR_BADPTR, "out_buffer is NULL" );
	demand_rn( lerp0 != NULL, X42_ERR_BADPTR, "lerp0 is NULL" );
	demand_rn( lerp1 != NULL, X42_ERR_BADPTR, "lerp1 is NULL" );
	demand_rn( blendValues != NULL, X42_ERR_BADPTR, "blendValues is NULL" );
	demand_rn( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" );
	demand_rn( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" );
#endif

	ret = (x42animLerp_t*)out_buffer;

	pv0 = lerp0->p;
	sv0 = lerp0->s;
	rv0 = lerp0->r;

	pv1 = lerp1->p;
	sv1 = lerp1->s;
	rv1 = lerp1->r;

	po = ret->p;
	so = ret->s;
	ro = ret->r;

	for( i = 0; i < x42->header.numAnimGroups; i++ )
	{
		uint beginBone = x42->animGroups[i].beginBone;
		uint endBone = x42->animGroups[i].endBone;

		float lerp = blendValues[i];

		for( j = beginBone; j < endBone; j++ )
		{
			vec3_lerp( po[j], pv0[j], pv1[j], lerp );
		}

		for( j = beginBone; j < endBone; j++ )
		{
			vec3_lerp( so[j], sv0[j], sv1[j], lerp );
		}

		for( j = beginBone; j < endBone; j++ )
		{
			quat_interp( ro[j], rv0[j], rv1[j], lerp );
		}
	}

	return ret;
}
Пример #11
0
RENDER_EXPORT void Q_EXTERNAL_CALL dllEntry( int (QDECL  *syscallptr)( int arg,... ) )
{
	REF_PARAM( syscallptr );
}