Esempio n. 1
0
/*
================
R_AliasDrawModel
================
*/
void R_AliasDrawModel(alight_t *plighting)
{
	finalvert_t		finalverts[MAXALIASVERTS +
							   ((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 1];
	auxvert_t		auxverts[MAXALIASVERTS];

	r_amodels_drawn++;

// cache align
	pfinalverts = (finalvert_t *)
				  (((long)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
	pauxverts = &auxverts[0];

	paliashdr = (aliashdr_t *)Mod_Extradata(currententity->model);
	pmdl = (mdl_t *)((byte *)paliashdr + paliashdr->model);

	R_AliasSetupSkin();
	R_AliasSetUpTransform(currententity->trivial_accept);
	R_AliasSetupLighting(plighting);
	R_AliasSetupFrame();

	if (!currententity->colormap)
	{
		Sys_Error("R_AliasDrawModel: !currententity->colormap");
	}

	r_affinetridesc.drawtype = (currententity->trivial_accept == 3) &&
							   r_recursiveaffinetriangles;

	if (r_affinetridesc.drawtype)
	{
		D_PolysetUpdateTables();		// FIXME: precalc...
	}
	else
	{
#if	id386
		D_Aff8Patch(currententity->colormap);
#endif
	}

	acolormap = currententity->colormap;

	if (currententity != &cl.viewent)
	{
		ziscale = (float)0x8000 * (float)0x10000;
	}
	else
	{
		ziscale = (float)0x8000 * (float)0x10000 * 3.0;
	}

	if (currententity->trivial_accept)
	{
		R_AliasPrepareUnclippedPoints();
	}
	else
	{
		R_AliasPreparePoints();
	}
}
Esempio n. 2
0
void
R_AliasDrawModel (alight_t *plighting)
{
	int          size;
	finalvert_t *finalverts;

	r_amodels_drawn++;

	if (!(paliashdr = currententity->model->aliashdr))
		paliashdr = Cache_Get (&currententity->model->cache);
	pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);

	size = (CACHE_SIZE - 1)
		+ sizeof (finalvert_t) * (pmdl->numverts + 1)
		+ sizeof (auxvert_t) * pmdl->numverts;
	finalverts = (finalvert_t *) Hunk_TempAlloc (size);
	if (!finalverts)
		Sys_Error ("R_AliasDrawModel: out of memory");

	// cache align
	pfinalverts = (finalvert_t *)
		(((intptr_t) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
	pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];

	R_AliasSetupSkin ();
	R_AliasSetUpTransform (currententity->trivial_accept);
	R_AliasSetupLighting (plighting);
	R_AliasSetupFrame ();

	r_affinetridesc.drawtype = (currententity->trivial_accept == 3) &&
		r_recursiveaffinetriangles;

	if (!acolormap)
		acolormap = vid.colormap8;

	if (r_affinetridesc.drawtype) {
		D_PolysetUpdateTables ();		// FIXME: precalc...
	} else {
#ifdef USE_INTEL_ASM
		D_Aff8Patch (acolormap);
#endif
	}

	if (currententity != vr_data.view_model)
		ziscale = (float) 0x8000 *(float) 0x10000;
	else
		ziscale = (float) 0x8000 *(float) 0x10000 *3.0;

	if (currententity->trivial_accept && pmdl->ident != HEADER_MDL16)
		R_AliasPrepareUnclippedPoints ();
	else
		R_AliasPreparePoints ();

	if (!currententity->model->aliashdr)
		Cache_Release (&currententity->model->cache);
}
Esempio n. 3
0
void
sw32_R_AliasDrawModel (alight_t *plighting)
{
	int         size;
	finalvert_t *finalverts;

	sw32_r_amodels_drawn++;

	if (!(paliashdr = currententity->model->aliashdr))
		paliashdr = Cache_Get (&currententity->model->cache);
	pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);

	size = (CACHE_SIZE - 1)
		   + sizeof (finalvert_t) * (pmdl->numverts + 1)
		   + sizeof (auxvert_t) * pmdl->numverts;
	finalverts = (finalvert_t *) Hunk_TempAlloc (size);
	if (!finalverts)
		Sys_Error ("R_AliasDrawModel: out of memory");

	// cache align
	pfinalverts = (finalvert_t *)
		(((intptr_t) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
	sw32_pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];

	R_AliasSetupSkin ();
	sw32_R_AliasSetUpTransform (currententity->trivial_accept);
	R_AliasSetupLighting (plighting);
	R_AliasSetupFrame ();

	if (!sw32_acolormap)
		sw32_acolormap = vid.colormap8;
	if (sw32_acolormap == &vid.colormap8 && sw32_r_pixbytes != 1)
	{
		if (sw32_r_pixbytes == 2)
			sw32_acolormap = vid.colormap16;
		else if (sw32_r_pixbytes == 4)
			sw32_acolormap = vid.colormap32;
		else
			Sys_Error("R_AliasDrawmodel: unsupported r_pixbytes %i",
					  sw32_r_pixbytes);
	}

	if (currententity != vr_data.view_model)
		sw32_ziscale = (float) 0x8000 *(float) 0x10000;
	else
		sw32_ziscale = (float) 0x8000 *(float) 0x10000 *3.0;

	if (currententity->trivial_accept)
		R_AliasPrepareUnclippedPoints ();
	else
		R_AliasPreparePoints ();

	if (!currententity->model->aliashdr)
		Cache_Release (&currententity->model->cache);
}
Esempio n. 4
0
/*
================
R_AliasDrawModel
================
*/
void R_AliasDrawModel(void)
{
    if (r_lerpmodels->integer == 0)
        currententity->backlerp = 0;

    if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND))
        r_refdef.xscale = -r_refdef.xscale;

    /*
    ** we have to set our frame pointers and transformations before
    ** doing any real work
    */
    R_AliasSetupFrames();
    R_AliasSetUpTransform();

    // see if the bounding box lets us trivially reject, also sets
    // trivial accept status
    if (R_AliasCheckBBox() == BBOX_TRIVIAL_REJECT)
        goto exit;

    // set up the skin and verify it exists
    R_AliasSetupSkin();

    r_amodels_drawn++;

    R_AliasSetupLighting();

    R_AliasSetupBlend();

    /*
    ** compute this_frame and old_frame addresses
    */
    R_AliasSetUpLerpData(currententity->backlerp);

    if (currententity->flags & RF_DEPTHHACK)
        s_ziscale = (float)0x8000 * (float)0x10000 * 3.0;
    else
        s_ziscale = (float)0x8000 * (float)0x10000;

    R_AliasPreparePoints();

exit:
    if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND))
        r_refdef.xscale = -r_refdef.xscale;
}
Esempio n. 5
0
/*
================
R_AliasDrawModel
================
*/
void
R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel)
{
	s_pmdl = (dmdl_t *)currentmodel->extradata;

	if ( r_lerpmodels->value == 0 )
		currententity->backlerp = 0;

	float oldAliasxscale = aliasxscale;
	float oldAliasyscale = aliasyscale;

	if ( currententity->flags & RF_WEAPONMODEL )
	{
		if ( r_lefthand->value == 2.0F )
		{
			return;
		}

		float gunfov = 2 * tan((float)r_gunfov->value / 360 * M_PI);
		aliasxscale = ((float)r_refdef.vrect.width / gunfov) * r_aliasuvscale;
		aliasyscale = aliasxscale;

		if ( r_lefthand->value == 1.0F )
			aliasxscale = -aliasxscale;
	}

	/*
	** we have to set our frame pointers and transformations before
	** doing any real work
	*/
	R_AliasSetupFrames(currententity, currentmodel, s_pmdl);
	R_AliasSetUpTransform(currententity);

	// see if the bounding box lets us trivially reject, also sets
	// trivial accept status
	if ( R_AliasCheckBBox(currententity) == BBOX_TRIVIAL_REJECT )
	{
		if ( currententity->flags & RF_WEAPONMODEL )
		{
			aliasxscale = oldAliasxscale;
			aliasyscale = oldAliasyscale;
		}
		return;
	}

	// set up the skin and verify it exists
	if ( !R_AliasSetupSkin(currententity, currentmodel) )
	{
		R_Printf( PRINT_ALL, "R_AliasDrawModel %s: NULL skin found\n",
			currentmodel->name);
		aliasxscale = oldAliasxscale;
		aliasyscale = oldAliasyscale;
		return;
	}

	r_amodels_drawn++;
	R_AliasSetupLighting(currententity);

	/*
	** select the proper span routine based on translucency
	*/
	// added double damage shell
	// reordered to handle blending
	if ( currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM) )
	{
		int		color;

		// added double
		color = currententity->flags & ( RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE | RF_SHELL_HALF_DAM);

		// reordered, new shells after old shells (so they get overriden)
		if ( color == RF_SHELL_RED )
			r_aliasblendcolor = SHELL_RED_COLOR;
		else if ( color == RF_SHELL_GREEN )
			r_aliasblendcolor = SHELL_GREEN_COLOR;
		else if ( color == RF_SHELL_BLUE )
			r_aliasblendcolor = SHELL_BLUE_COLOR;
		else if ( color == (RF_SHELL_RED | RF_SHELL_GREEN) )
			r_aliasblendcolor = SHELL_RG_COLOR;
		else if ( color == (RF_SHELL_RED | RF_SHELL_BLUE) )
			r_aliasblendcolor = SHELL_RB_COLOR;
		else if ( color == (RF_SHELL_BLUE | RF_SHELL_GREEN) )
			r_aliasblendcolor = SHELL_BG_COLOR;
		// added this .. it's yellowish
		else if ( color == (RF_SHELL_DOUBLE) )
			r_aliasblendcolor = SHELL_DOUBLE_COLOR;
		else if ( color == (RF_SHELL_HALF_DAM) )
			r_aliasblendcolor = SHELL_HALF_DAM_COLOR;
		else
			r_aliasblendcolor = SHELL_WHITE_COLOR;

		if ( currententity->alpha > 0.33 )
			d_pdrawspans = R_PolysetDrawSpansConstant8_66;
		else
			d_pdrawspans = R_PolysetDrawSpansConstant8_33;
	}
	else if ( currententity->flags & RF_TRANSLUCENT )
	{
		if ( currententity->alpha > 0.66 )
			d_pdrawspans = R_PolysetDrawSpans8_Opaque;
		else if ( currententity->alpha > 0.33 )
			d_pdrawspans = R_PolysetDrawSpans8_66;
		else
			d_pdrawspans = R_PolysetDrawSpans8_33;
	}
	else
	{
		d_pdrawspans = R_PolysetDrawSpans8_Opaque;
	}

	/*
	** compute this_frame and old_frame addresses
	*/
	R_AliasSetUpLerpData(currententity, s_pmdl, currententity->backlerp);

	if (currententity->flags & RF_DEPTHHACK)
		s_ziscale = (float)0x8000 * (float)SHIFT16XYZ_MULT * 3.0;
	else
		s_ziscale = (float)0x8000 * (float)SHIFT16XYZ_MULT;

	R_AliasPreparePoints(currententity, finalverts, finalverts_max);

	if ( currententity->flags & RF_WEAPONMODEL )
	{
		aliasxscale = oldAliasxscale;
		aliasyscale = oldAliasyscale;
	}
}
Esempio n. 6
0
/*
================
R_AliasDrawModel
================
*/
void R_AliasDrawModel (alight_t *plighting)
{
finalvert_t		finalverts[MAXALIASVERTS + ((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 1];
        auxvert_t      	auxverts[MAXALIASVERTS];
//	finalvert_t		*finalverts;
//	auxvert_t		*auxverts;


	//Anders> Change malloc to static allocated memory to avoid malloc?
	//  	finalverts = malloc( (sizeof(finalvert_t)*MAXALIASVERTS) + (sizeof(finalvert_t)*(((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 1)));
	//        auxverts   = malloc( (sizeof(finalvert_t)*MAXALIASVERTS));

	GpError("R_AliasDrawModel A",11);

	r_amodels_drawn++;

// cache align
	pfinalverts = (finalvert_t *)
			(((long)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
	pauxverts = &auxverts[0];

	GpError("R_AliasDrawModel B",11);

	paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);
	pmdl = (mdl_t *)((byte *)paliashdr + paliashdr->model);

	GpError("R_AliasDrawModel C",11);
	R_AliasSetupSkin ();
	GpError("R_AliasDrawModel D",11);
	R_AliasSetUpTransform (currententity->trivial_accept);
	GpError("R_AliasDrawModel E",11);
	R_AliasSetupLighting (plighting);
	GpError("R_AliasDrawModel F",11);
	R_AliasSetupFrame ();
	GpError("R_AliasDrawModel G",11);

	if (!currententity->colormap)
		Sys_Error ("R_AliasDrawModel: !currententity->colormap");

	r_affinetridesc.drawtype = (currententity->trivial_accept == 3) &&
			r_recursiveaffinetriangles;

	if (r_affinetridesc.drawtype)
	{
		GpError("R_AliasDrawModel H",11);
		D_PolysetUpdateTables ();		// FIXME: precalc...
	}
	else
	{
#if	id386
		D_Aff8Patch (currententity->colormap);
#endif
	}

	acolormap = currententity->colormap;

	if (currententity != &cl.viewent)
		ziscale = (float)0x8000 * (float)0x10000;
	else
		ziscale = (float)0x8000 * (float)0x10000 * 3.0;

	if (currententity->trivial_accept){
		GpError("R_AliasDrawModel I",11);
		R_AliasPrepareUnclippedPoints ();
	}
	else{
		GpError("R_AliasDrawModel J",11);
		R_AliasPreparePoints ();
	}
	//		free(finalverts);
	//		free(auxverts);
	GpError("R_AliasDrawModel end",11);
}
Esempio n. 7
0
void R_AliasDrawModel (alight_t *plighting)
#endif
{
// h2
	int		mls;
	int		i, j;
	byte	*dest, *source, *sourceA;
// h2

	finalvert_t		finalverts[MAXALIASVERTS +
						((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 1];
	auxvert_t		auxverts[MAXALIASVERTS];

	r_amodels_drawn++;

// cache align
	pfinalverts = (finalvert_t *)
			(((long)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));


#ifdef INTERPOL7
	if(r_lerpmodels->value)
	pauxverts = &r_auxverts[0];
	else
	pauxverts = &auxverts[0];
#else
	pauxverts = &auxverts[0];
#endif
	paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);
	pmdl = (mdl_t *)((byte *)paliashdr + paliashdr->model);

	R_AliasSetupSkin ();
#ifdef INTERPOL7
	if (r_lerpmodels->value)
	R_AliasSetUpTransform (0);
		else
	R_AliasSetUpTransform (currententity->trivial_accept);
//	R_AliasSetUpTransform (currententity->trivial_accept);
#else
	R_AliasSetUpTransform (currententity->trivial_accept);
#endif
	if (r_shading->value > 1 && (lightingavailable))
		R_AliasSetupLighting_enhanced (plighting);	// leilei - further hacked
	else if (r_shading->value > 1 && !lightingavailable)
		R_AliasSetupLighting (plighting);	// no lighting available so we fall back
		else
		if (r_shading->value)
		R_AliasSetupLighting (plighting);
		else
			R_AliasSetupLightingSimple (plighting);
#ifdef INTERPOL7
		R_AliasSetupFrame (currententity);
#else
		R_AliasSetupFrame ();
#endif


	if (!currententity->colormap)
		Sys_Error ("R_AliasDrawModel: !currententity->colormap");

	if (!coloredlights){
	r_affinetridesc.drawtype = (currententity->trivial_accept == 3) &&
			r_recursiveaffinetriangles;
	}
	
	if (r_affinetridesc.drawtype)
	{
		D_PolysetUpdateTables ();		// FIXME: precalc...

	}
	else
	{
#if	id386broken
		D_Aff8Patch (currententity->colormap);
#endif
	}

	acolormap = currententity->colormap;
#ifdef VMTOC
//	if (viewmodel)
//		ziscale = (float)0x8000 * (float)0x10000 * 3.0;
//	else
	 if (viewmodel)
		ziscale = (float)0x8000 * (float)0x10000 * 3.0;
	else
		ziscale = (float)0x8000 * (float)0x10000;
#else
	if (currententity != &cl.viewent)
		ziscale = (float)0x8000 * (float)0x10000;
	 else
		ziscale = (float)0x8000 * (float)0x10000 * 3.0;
#endif
	if (currententity->trivial_accept)
		R_AliasPrepareUnclippedPoints ();
	else
		R_AliasPreparePoints ();
}