Example #1
0
/*
================
R_AliasPreparePoints

General clipped case
================
*/
static void R_AliasPreparePoints(void)
{
    int         i;
    maliasst_t  *pstverts;
    maliastri_t *ptri;
    finalvert_t *pfv[3];
    finalvert_t finalverts[MAX_ALIAS_VERTS +
                           ((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 3];
    finalvert_t *pfinalverts;

    // put work vertexes on stack, cache aligned
    pfinalverts = (finalvert_t *)
                  (((uintptr_t)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));

    R_AliasTransformFinalVerts(currentmodel->numverts, pfinalverts,
                               r_lastframe->verts, r_thisframe->verts);

// clip and draw all triangles
//
    pstverts = currentmodel->sts;
    ptri = currentmodel->tris;

    if ((currententity->flags & (RF_WEAPONMODEL | RF_LEFTHAND)) == (RF_WEAPONMODEL | RF_LEFTHAND)) {
        for (i = 0; i < currentmodel->numtris; i++, ptri++) {
            pfv[0] = &pfinalverts[ptri->index_xyz[0]];
            pfv[1] = &pfinalverts[ptri->index_xyz[1]];
            pfv[2] = &pfinalverts[ptri->index_xyz[2]];

            if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags)
                continue;       // completely clipped

            // insert s/t coordinates
            pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
            pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;

            pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
            pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;

            pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
            pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;

            if (!(pfv[0]->flags | pfv[1]->flags | pfv[2]->flags)) {
                // totally unclipped
                aliastriangleparms.a = pfv[2];
                aliastriangleparms.b = pfv[1];
                aliastriangleparms.c = pfv[0];

                R_DrawTriangle();
            } else {
                R_AliasClipTriangle(pfv[2], pfv[1], pfv[0]);
            }
        }
    } else {
        for (i = 0; i < currentmodel->numtris; i++, ptri++) {
            pfv[0] = &pfinalverts[ptri->index_xyz[0]];
            pfv[1] = &pfinalverts[ptri->index_xyz[1]];
            pfv[2] = &pfinalverts[ptri->index_xyz[2]];

            if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags)
                continue;       // completely clipped

            // insert s/t coordinates
            pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
            pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;

            pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
            pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;

            pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
            pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;

            if (!(pfv[0]->flags | pfv[1]->flags | pfv[2]->flags)) {
                // totally unclipped
                aliastriangleparms.a = pfv[0];
                aliastriangleparms.b = pfv[1];
                aliastriangleparms.c = pfv[2];

                R_DrawTriangle();
            } else {
                // partially clipped
                R_AliasClipTriangle(pfv[0], pfv[1], pfv[2]);
            }
        }
    }
}
Example #2
0
static void
R_AliasPreparePoints (const entity_t *currententity, finalvert_t *verts, const finalvert_t *verts_max)
{
	int		i;
	dstvert_t	*pstverts;
	dtriangle_t	*ptri;
	finalvert_t	*pfv[3];

	if ((verts + s_pmdl->num_xyz) >= verts_max)
	{
		r_outofverts = true;
		return;
	}

	R_AliasTransformFinalVerts(currententity,
				   s_pmdl->num_xyz,
				   verts,	// destination for transformed verts
				   r_lastframe->verts,	// verts from the last frame
				   r_thisframe->verts	// verts from this frame
				);

	// clip and draw all triangles
	//
	pstverts = (dstvert_t *)((byte *)s_pmdl + s_pmdl->ofs_st);
	ptri = (dtriangle_t *)((byte *)s_pmdl + s_pmdl->ofs_tris);

	if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
	{
		for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
		{
			pfv[0] = &verts[ptri->index_xyz[0]];
			pfv[1] = &verts[ptri->index_xyz[1]];
			pfv[2] = &verts[ptri->index_xyz[2]];

			if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
				continue;	// completely clipped

			// insert s/t coordinates
			pfv[0]->s = pstverts[ptri->index_st[0]].s << SHIFT16XYZ;
			pfv[0]->t = pstverts[ptri->index_st[0]].t << SHIFT16XYZ;

			pfv[1]->s = pstverts[ptri->index_st[1]].s << SHIFT16XYZ;
			pfv[1]->t = pstverts[ptri->index_st[1]].t << SHIFT16XYZ;

			pfv[2]->s = pstverts[ptri->index_st[2]].s << SHIFT16XYZ;
			pfv[2]->t = pstverts[ptri->index_st[2]].t << SHIFT16XYZ;

			if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
			{
				// totally unclipped
				R_DrawTriangle(currententity, pfv[2], pfv[1], pfv[0]);
			}
			else
			{
				R_AliasClipTriangle(currententity, pfv[2], pfv[1], pfv[0]);
			}
		}
	}
	else
	{
		for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
		{
			pfv[0] = &verts[ptri->index_xyz[0]];
			pfv[1] = &verts[ptri->index_xyz[1]];
			pfv[2] = &verts[ptri->index_xyz[2]];

			if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
				continue;	// completely clipped

			// insert s/t coordinates
			pfv[0]->s = pstverts[ptri->index_st[0]].s << SHIFT16XYZ;
			pfv[0]->t = pstverts[ptri->index_st[0]].t << SHIFT16XYZ;

			pfv[1]->s = pstverts[ptri->index_st[1]].s << SHIFT16XYZ;
			pfv[1]->t = pstverts[ptri->index_st[1]].t << SHIFT16XYZ;

			pfv[2]->s = pstverts[ptri->index_st[2]].s << SHIFT16XYZ;
			pfv[2]->t = pstverts[ptri->index_st[2]].t << SHIFT16XYZ;

			if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
			{
				// totally unclipped
				R_DrawTriangle(currententity, pfv[0], pfv[1], pfv[2]);
			}
			else
			{	// partially clipped
				R_AliasClipTriangle(currententity, pfv[0], pfv[1], pfv[2]);
			}
		}
	}
}
Example #3
0
void R_AliasPreparePoints (void)
{
	int			i;
	dstvert_t	*pstverts;
	dtriangle_t	*ptri;
	finalvert_t	*pfv[3];
	finalvert_t	finalverts[MAXALIASVERTS +
						((CACHE_SIZE - 1) / sizeof(finalvert_t)) + 3];
	finalvert_t	*pfinalverts;

//PGM
	iractive = (r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE);
//	iractive = 0;
//	if(r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
//		iractive = 1;
//PGM

	// put work vertexes on stack, cache aligned
	pfinalverts = (finalvert_t *)
			(((long)&finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));

	aliasbatchedtransformdata.num_points = s_pmdl->num_xyz;
	aliasbatchedtransformdata.last_verts = r_lastframe->verts;
	aliasbatchedtransformdata.this_verts = r_thisframe->verts;
	aliasbatchedtransformdata.dest_verts = pfinalverts;

	R_AliasTransformFinalVerts( aliasbatchedtransformdata.num_points,
		                        aliasbatchedtransformdata.dest_verts,
								aliasbatchedtransformdata.last_verts,
								aliasbatchedtransformdata.this_verts );

// clip and draw all triangles
//
	pstverts = (dstvert_t *)((byte *)s_pmdl + s_pmdl->ofs_st);
	ptri = (dtriangle_t *)((byte *)s_pmdl + s_pmdl->ofs_tris);

	if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
	{
		for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
		{
			pfv[0] = &pfinalverts[ptri->index_xyz[0]];
			pfv[1] = &pfinalverts[ptri->index_xyz[1]];
			pfv[2] = &pfinalverts[ptri->index_xyz[2]];

			if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
				continue;		// completely clipped

			// insert s/t coordinates
			pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
			pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;

			pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
			pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;

			pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
			pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;

			if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
			{	// totally unclipped
				aliastriangleparms.a = pfv[2];
				aliastriangleparms.b = pfv[1];
				aliastriangleparms.c = pfv[0];

				R_DrawTriangle();
			}
			else
			{
				R_AliasClipTriangle (pfv[2], pfv[1], pfv[0]);
			}
		}
	}
	else
	{
#ifdef RAPTOR_RAYTRACE
	    int num_light_triangles_pushed=0;
	    vec3_t centre = {0,0,0};
        float scale = (sin(r_newrefdef.time*7)+1)/2.0f; // For pulsating light
#endif
        for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
		{
            pfv[0] = &pfinalverts[ptri->index_xyz[0]];
			pfv[1] = &pfinalverts[ptri->index_xyz[1]];
			pfv[2] = &pfinalverts[ptri->index_xyz[2]];

#ifndef RAPTOR_RAYTRACE
			if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
				continue;		// completely clipped
#endif//RAPTOR_RAYTRACE

			// insert s/t coordinates
			pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
			pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;

			pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
			pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;

			pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
			pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;

			if (1)//! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
			{	// totally unclipped
				aliastriangleparms.a = pfv[0];
				aliastriangleparms.b = pfv[1];
				aliastriangleparms.c = pfv[2];

#ifdef RAPTOR_RAYTRACE
{
                int index;
                float local[3][3];

                for (index=0; index<3; ++index)
                {
                    local[index][0] =  pfv[index]->xyz[0];
                    local[index][1] = -pfv[index]->xyz[1];
                    local[index][2] =  pfv[index]->xyz[2];
                }

                // Do not add triangles where the vertexes form a straight line (0 area).
                if (raptor_is_straight_line(local[0], local[1], local[2]))
                    continue;

#ifdef RAPTOR_TEXTURE_MAPPING_ON
{
                vec3_t dummy = {0,0,0};

                assert(currententity->model->skins[0]->pixels[0]);
                assert(currententity->model->skins[0]->width);
                assert(currententity->model->skins[0]->height);

                // Add a skin for the current triangle. NOTE: since there are s,t coordinates,
                // the n, up, right vectors are not used (dummy).
                raptor_push_triangle_texture(currententity->model->skins[0]->pixels[0],
                                             currententity->model->skins[0]->width,
                                             currententity->model->skins[0]->height,
                                             dummy,
                                             dummy,
                                             dummy,
                                             pfv[0]->s>>16,
                                             pfv[0]->t>>16,
                                             pfv[1]->s>>16,
                                             pfv[1]->t>>16,
                                             pfv[2]->s>>16,
                                             pfv[2]->t>>16);

                if (currententity->flags & RF_GLOW)
                {
                    // For glowing items, specify that the triangles should be associated with a light.
                    raptor_push_triangle(local[0], local[1], local[2], 1, (1.0f-scale)*BONUS_ITEM_LIGHT_RED, (1.0f-scale)*BONUS_ITEM_LIGHT_GREEN, (1.0f-scale)*BONUS_ITEM_LIGHT_BLUE, raptor_triangle_light);
                    // Add upp triangle coordinates and count number of triangles so centre point of light
                    // can be calculated later.
                    VectorAdd(centre, local[0], centre);
                    VectorAdd(centre, local[1], centre);
                    VectorAdd(centre, local[2], centre);
                    ++num_light_triangles_pushed;
                }
                else
                {
                    raptor_push_triangle(local[0], local[1], local[2], 1, 255, 255, 255, raptor_is_not_a_light);
                }
}
#else
                raptor_push_triangle(local[0], local[1], local[2], 0, 255, 255, 255, raptor_is_not_a_light);
#endif//RAPTOR_TEXTURE_MAPPING_ON
}
#else
				R_DrawTriangle();
#endif
			}
			else		
			{	// partially clipped
			    R_AliasClipTriangle (pfv[0], pfv[1], pfv[2]);
			}
		}