示例#1
0
char *storage_serialize_sf(void *ptr, u32 fieldType)
{
	char szVal[50];
	switch (fieldType) {
	case GF_SG_VRML_SFBOOL:
		sprintf(szVal, "%d", *((SFBool *)ptr) ? 1 : 0);
		return gf_strdup(szVal);
	case GF_SG_VRML_SFINT32:
		sprintf(szVal, "%d",  *((SFInt32 *)ptr) );
		return gf_strdup(szVal);
	case GF_SG_VRML_SFTIME:
		sprintf(szVal, "%g", *((SFTime *)ptr) );
		return gf_strdup(szVal);
	case GF_SG_VRML_SFFLOAT:
		sprintf(szVal, "%g", FIX2FLT( *((SFFloat *)ptr) ) );
		return gf_strdup(szVal);
	case GF_SG_VRML_SFVEC2F:
		sprintf(szVal, "%g %g", FIX2FLT( ((SFVec2f *)ptr)->x), FIX2FLT( ((SFVec2f *)ptr)->y) );
		return gf_strdup(szVal);
	case GF_SG_VRML_SFVEC3F:
		sprintf(szVal, "%g %g %g", FIX2FLT( ((SFVec3f *)ptr)->x), FIX2FLT( ((SFVec3f *)ptr)->y) , FIX2FLT( ((SFVec3f *)ptr)->z) );
		return gf_strdup(szVal);
	case GF_SG_VRML_SFSTRING:
		return gf_strdup( ((SFString *)ptr)->buffer ? ((SFString *)ptr)->buffer : "");

	default:
		break;
	}
	return NULL;
}
示例#2
0
void C_DECL A_LeafCheck(mobj_t *actor)
{
    int                 n;

    actor->special1++;
    if(actor->special1 >= 20)
    {
        P_MobjChangeState(actor, S_NULL);
        return;
    }

    if(P_Random() > 64)
    {
        if(FEQUAL(actor->mom[MX], 0) && FEQUAL(actor->mom[MY], 0))
        {
            P_ThrustMobj(actor, actor->target->angle,
                         FIX2FLT(P_Random() << 9) + 1);
        }
        return;
    }

    P_MobjChangeState(actor, S_LEAF1_8);
    n = P_Random();
    actor->mom[MZ] = FIX2FLT(n << 9) + 1;
    P_ThrustMobj(actor, actor->target->angle, FIX2FLT(P_Random() << 9) + 2);
    actor->flags |= MF_MISSILE;
}
示例#3
0
文件: camera.c 项目: Brilon314/gpac
static void camera_frustum_from_matrix(GF_Camera *cam, GF_Matrix *mx)
{
	u32 i;

	cam->planes[FRUS_LEFT_PLANE].normal.x = mx->m[3] + mx->m[0];
	cam->planes[FRUS_LEFT_PLANE].normal.y = mx->m[7] + mx->m[4];
	cam->planes[FRUS_LEFT_PLANE].normal.z = mx->m[11] + mx->m[8];
	cam->planes[FRUS_LEFT_PLANE].d = mx->m[15] + mx->m[12];

	cam->planes[FRUS_RIGHT_PLANE].normal.x = mx->m[3] - mx->m[0];
	cam->planes[FRUS_RIGHT_PLANE].normal.y = mx->m[7] - mx->m[4];
	cam->planes[FRUS_RIGHT_PLANE].normal.z = mx->m[11] - mx->m[8];
	cam->planes[FRUS_RIGHT_PLANE].d = mx->m[15] - mx->m[12];

	cam->planes[FRUS_BOTTOM_PLANE].normal.x = mx->m[3] + mx->m[1];
	cam->planes[FRUS_BOTTOM_PLANE].normal.y = mx->m[7] + mx->m[5];
	cam->planes[FRUS_BOTTOM_PLANE].normal.z = mx->m[11] + mx->m[9];
	cam->planes[FRUS_BOTTOM_PLANE].d = mx->m[15] + mx->m[13];

	cam->planes[FRUS_TOP_PLANE].normal.x = mx->m[3] - mx->m[1];
	cam->planes[FRUS_TOP_PLANE].normal.y = mx->m[7] - mx->m[5];
	cam->planes[FRUS_TOP_PLANE].normal.z = mx->m[11] - mx->m[9];
	cam->planes[FRUS_TOP_PLANE].d = mx->m[15] - mx->m[13];

	cam->planes[FRUS_FAR_PLANE].normal.x = mx->m[3] - mx->m[2];
	cam->planes[FRUS_FAR_PLANE].normal.y = mx->m[7] - mx->m[6];
	cam->planes[FRUS_FAR_PLANE].normal.z = mx->m[11] - mx->m[10];
	cam->planes[FRUS_FAR_PLANE].d = mx->m[15] - mx->m[14];

	cam->planes[FRUS_NEAR_PLANE].normal.x = mx->m[3] + mx->m[2];
	cam->planes[FRUS_NEAR_PLANE].normal.y = mx->m[7] + mx->m[6];
	cam->planes[FRUS_NEAR_PLANE].normal.z = mx->m[11] + mx->m[10];
	cam->planes[FRUS_NEAR_PLANE].d = mx->m[15] + mx->m[14];

	for (i=0; i<6; ++i) {
#ifdef GPAC_FIXED_POINT
		/*after some testing, it's just safer to move back to float here, the smallest drift will
		result in completely wrong culling...*/
		Float vx, vy, vz, nor;
		vx = FIX2FLT(cam->planes[i].normal.x);
		vy = FIX2FLT(cam->planes[i].normal.y);
		vz = FIX2FLT(cam->planes[i].normal.z);
		nor = (Float) sqrt(vx*vx + vy*vy + vz*vz);
		vx /= nor;
		vy /= nor;
		vz /= nor;
		cam->planes[i].d = FLT2FIX (FIX2FLT(cam->planes[i].d) / nor);
		cam->planes[i].normal.x = FLT2FIX(vx);
		cam->planes[i].normal.y = FLT2FIX(vy);
		cam->planes[i].normal.z = FLT2FIX(vz);
#else
		Float len = (Float)(1.0f / gf_vec_len(cam->planes[i].normal));
		cam->planes[i].normal = gf_vec_scale(cam->planes[i].normal, len);
		cam->planes[i].d *= len;
#endif

		/*compute p-vertex idx*/
		cam->p_idx[i] = gf_plane_get_p_vertex_idx(&cam->planes[i]);
	}
}
示例#4
0
	/**
	 * Debug print
	 */
	void print ( void )
	{
		lprintfln( "{%f, %f, %f}",
				   FIX2FLT( m_x ),
				   FIX2FLT( m_y ),
				   FIX2FLT( m_z ) );
	}
示例#5
0
void C_DECL A_FogMove(mobj_t* actor)
{
    coord_t speed = (coord_t) actor->args[0];
    uint an;

    if(!(actor->args[4]))
        return;

    if(actor->args[3]-- <= 0)
    {
        P_MobjChangeStateNoAction(actor, P_GetState(actor->type, SN_DEATH));
        return;
    }

    // Move the fog slightly/slowly up and down. Some fog patches are supposed
    // to move higher and some are supposed to stay close to the ground.
    // Unlike in the original Hexen, the move is done by applying momentum
    // to the cloud so that the movement is smooth.
    if((actor->args[3] % 4) == 0)
    {
        uint weaveindex = actor->special2;
        actor->mom[VZ] = FLOATBOBOFFSET(weaveindex) / TICSPERSEC;
        actor->special2 = (weaveindex + 1) & 63;
    }

    an = actor->angle >> ANGLETOFINESHIFT;
    actor->mom[MX] = speed * FIX2FLT(finecosine[an]);
    actor->mom[MY] = speed * FIX2FLT(finesine[an]);
}
示例#6
0
static void swf_svg_print_matrix(SWFReader *read, GF_Matrix2D *mat)
{
    if (!gf_mx2d_is_identity(*mat))
    {
        GF_Point2D  scale;
        GF_Point2D  translate;
        Fixed       rotate;
        if( gf_mx2d_decompose(mat, &scale, &rotate, &translate)) 
        {
            fprintf(read->svg_output, "transform=\"");
            if (translate.x != 0 || translate.y != 0)
            {
                fprintf(read->svg_output, "translate(%f, %f) ", FIX2FLT(translate.x), FIX2FLT(translate.y));
            }
            if (rotate != 0)
            {
                fprintf(read->svg_output, "rotate(%f) ", FIX2FLT(rotate));
            }
            if (scale.x != FIX_ONE || scale.y != FIX_ONE)
            {
                fprintf(read->svg_output, "scale(%f, %f) ", FIX2FLT(scale.x), FIX2FLT(scale.y));
            }
            fprintf(read->svg_output, "\" ");
        } 
        else 
        {
            fprintf(read->svg_output, "transform=\"matrix(%f,%f,%f,%f,%f,%f)\" ", FIX2FLT(mat->m[0]), FIX2FLT(mat->m[3]), FIX2FLT(mat->m[1]), FIX2FLT(mat->m[4]), FIX2FLT(mat->m[2]), FIX2FLT(mat->m[5]) );
        }
    }
}
示例#7
0
static void c2d_gl_fill_alpha(void *cbk, u32 x, u32 y, u32 run_h_len, GF_Color color, u8 alpha)
{
#if defined(GPAC_USE_OGL_ES)
	GLfloat line[4];

	line[0] = FIX2FLT(x);
	line[1] = FIX2FLT(y);
	line[2] = FIX2FLT(x+run_h_len);
	line[3] = line[1];

	glEnable(GL_BLEND);
	glColor4ub(GF_COL_R(color), GF_COL_G(color), GF_COL_B(color), (u8) alpha);

	glVertexPointer(2, GL_FLOAT, 0, line);
	glEnableClientState(GL_VERTEX_ARRAY);
	glDrawArrays(GL_LINES, 0, 2);
	glDisableClientState(GL_VERTEX_ARRAY);

	glDisable(GL_BLEND);
#else
	glEnable(GL_BLEND);
	glColor4ub(GF_COL_R(color), GF_COL_G(color), GF_COL_B(color), (u8) alpha);
	glBegin(GL_LINES);
	glVertex2i(x,y);
	glVertex2i(x+run_h_len,y);
	glEnd();
	glDisable(GL_BLEND);
#endif
}
示例#8
0
mobj_t *P_LaunchMissile(mobj_t *missile, angle_t angle, coord_t const targetPos[],
    coord_t const sourcePos[], coord_t extraMomZ)
{
    DENG2_ASSERT(targetPos);
    if(missile)
    {
        DENG2_ASSERT(missile->info);

        // Play the launch sound.
        if(missile->info->seeSound)
        {
            S_StartSound(missile->info->seeSound, missile);
        }

        if(!sourcePos)
        {
            sourcePos = missile->origin;
        }

        // Determine speed.
        /// @todo Should optionally calculate this in true 3D.
        coord_t dist;
        uint an = angle >> ANGLETOFINESHIFT;
        missile->mom[0] = missile->info->speed * FIX2FLT(finecosine[an]);
        missile->mom[1] = missile->info->speed * FIX2FLT(finesine  [an]);

        dist = M_ApproxDistance(targetPos[0] - sourcePos[0], targetPos[1] - sourcePos[1]);
        dist /= missile->info->speed;
        if(dist < 1) dist = 1;

        missile->mom[2] = (targetPos[2] - sourcePos[2] + extraMomZ) / dist;
    }
    return Mobj_ExplodeIfObstructed(missile);
}
示例#9
0
void C_DECL A_PotteryExplode(mobj_t* actor)
{
    int i, maxBits = (P_Random() & 3) + 3;
    mobj_t* potteryBit;

    for(i = 0; i < maxBits; ++i)
    {
        if((potteryBit = P_SpawnMobj(MT_POTTERYBIT1, actor->origin, P_Random() << 24, 0)))
        {
            P_MobjChangeState(potteryBit, P_GetState(potteryBit->type, SN_SPAWN) + (P_Random() % 5));

            potteryBit->mom[MZ] = FIX2FLT(((P_Random() & 7) + 5) * (3 * FRACUNIT / 4));
            potteryBit->mom[MX] = FIX2FLT((P_Random() - P_Random()) << 10);
            potteryBit->mom[MY] = FIX2FLT((P_Random() - P_Random()) << 10);
        }
    }

    S_StartSound(SFX_POTTERY_EXPLODE, potteryBit);

    if(actor->args[0])
    {
        // Spawn an item.
        if(!G_Ruleset_NoMonsters() ||
                !(MOBJINFO[TranslateThingType[actor->args[0]]].
                  flags & MF_COUNTKILL))
        {
            // Only spawn monsters if not -nomonsters.
            P_SpawnMobj(TranslateThingType[actor->args[0]], actor->origin,
                        actor->angle, 0);
        }
    }

    P_MobjRemove(actor, false);
}
示例#10
0
void C_DECL A_LeafSpawn(mobj_t* actor)
{
    coord_t pos[3];
    mobj_t* mo;
    int i;

    for(i = (P_Random() & 3) + 1; i; i--)
    {
        pos[VX] = actor->origin[VX];
        pos[VY] = actor->origin[VY];
        pos[VZ] = actor->origin[VZ];

        pos[VX] += FIX2FLT((P_Random() - P_Random()) << 14);
        pos[VY] += FIX2FLT((P_Random() - P_Random()) << 14);
        pos[VZ] += FIX2FLT(P_Random() << 14);

        /// @todo  We should not be using the original indices to determine
        ///         the mobjtype. Use a local table instead.
        if((mo = P_SpawnMobj(MT_LEAF1 + (P_Random() & 1), pos,
                             actor->angle, 0)))
        {
            P_ThrustMobj(mo, actor->angle, FIX2FLT(P_Random() << 9) + 3);
            mo->target = actor;
            mo->special1 = 0;
        }
    }
}
示例#11
0
文件: swf_svg.c 项目: ARSekkat/gpac
static void swf_svg_print_color(SWFReader *read, u32 ARGB)
{
	SFColor val;
	val.red = INT2FIX((ARGB>>16)&0xFF) / 255*100;
	val.green = INT2FIX((ARGB>>8)&0xFF) / 255*100;
	val.blue = INT2FIX((ARGB)&0xFF) / 255*100;
	swf_svg_print(read, "rgb(%g%%,%g%%,%g%%)", FIX2FLT(val.red), FIX2FLT(val.green), FIX2FLT(val.blue));
}
示例#12
0
void BE_WriteSFFloat(GF_BifsEncoder *codec, Fixed val, GF_BitStream *bs, char *com)
{
	if (codec->ActiveQP && codec->ActiveQP->useEfficientCoding) {
		gf_bifs_enc_mantissa_float(codec, val, bs);
	} else {
		gf_bs_write_float(bs, FIX2FLT(val));
		GF_LOG(GF_LOG_DEBUG, GF_LOG_CODING, ("[BIFS] SFFloat\t\t32\t\t%g\t\t%s\n", FIX2FLT(val), com ? com : "") );
	}
}
示例#13
0
	void print ( void )
	{
		for ( int i = 0; i < 4; i++ )
			printf( "{%f, %f, %f, %f}",
					FIX2FLT( m_matrix[i][0] ),
					FIX2FLT( m_matrix[i][1] ),
					FIX2FLT( m_matrix[i][2] ),
					FIX2FLT( m_matrix[i][3] ) );
	}
示例#14
0
static Bool gf_cache_remove_entry(GF_Compositor *compositor, GF_Node *node, GroupingNode2D *group)
{
	u32 bytes_remove = 0;
	GF_List *cache_candidates = compositor->cached_groups;

	/*auto mode*/
	if (!group) {
		group = gf_list_get(cache_candidates, 0);
		if (!group) return 0;
		/*remove entry*/
		gf_list_rem(cache_candidates, 0);
		node = NULL;
	} else {
		/*remove entry if present*/
		if (gf_list_del_item(cache_candidates, group)<0)
			return 0;
	}

	/*disable the caching flag of the group if it was marked as such*/
	if(group->flags & GROUP_IS_CACHABLE) {
		group->flags &= ~GROUP_IS_CACHABLE;
		/*the discarded bytes*/
		bytes_remove = group->cached_size;
	}

	/*indicates cache destruction for next frame*/
	if (group->cache && (group->flags & GROUP_IS_CACHED)) {
		group->flags &= ~GROUP_IS_CACHED;
		/*the discarded bytes*/
		bytes_remove = group->cached_size;
	}

	if (bytes_remove == 0) return 0;

	assert(compositor->video_cache_current_size >= bytes_remove);
	compositor->video_cache_current_size -= bytes_remove;

	GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Removing cache %s:\t Objects: %d\tSlope: %g\tBytes: %d\tTime: %d\n",
										gf_node_get_log_name(node),
										group->nb_objects,
										FIX2FLT(group->priority),
										group->cached_size,
										FIX2FLT(group->traverse_time)));

	GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Status (B): Max: %d\tUsed: %d\tNb Groups: %d\n",
								compositor->video_cache_max_size,
								compositor->video_cache_current_size,
								gf_list_count(compositor->cached_groups)
								));
	return 1;
}
示例#15
0
/**
 * Get a pointer to the value of a variable. Added for 64-bit support.
 */
void *G_GetVariable(int id)
{
    static float bob[2];

    switch(id)
    {
    case DD_GAME_NAME:
        return GAMENAMETEXT;

    case DD_GAME_NICENAME:
        return GAME_NICENAME;

    case DD_GAME_ID:
        return GAMENAMETEXT " " GAME_VERSION_TEXT;

    case DD_GAME_MODE:
        return gameModeString;

    case DD_GAME_CONFIG:
        return gameConfigString;

    case DD_VERSION_SHORT:
        return GAME_VERSION_TEXT;

    case DD_VERSION_LONG:
        return GAME_VERSION_TEXTLONG "\n" GAME_DETAILS;

    case DD_ACTION_LINK:
        return actionlinks;

    case DD_XGFUNC_LINK:
        return xgClasses;

    case DD_PSPRITE_BOB_X:
        bob[VX] = 1 + (cfg.bobWeapon * players[CONSOLEPLAYER].bob) *
            FIX2FLT(finecosine[(128 * mapTime) & FINEMASK]);

        return &bob[VX];

    case DD_PSPRITE_BOB_Y:
        bob[VY] = 32 + (cfg.bobWeapon * players[CONSOLEPLAYER].bob) *
            FIX2FLT(finesine[(128 * mapTime) & FINEMASK & (FINEANGLES / 2 - 1)]);

        return &bob[VY];

    default:
        break;
    }
    // ID not recognized, return NULL.
    return 0;
}
示例#16
0
dd_bool EV_ThingProjectile(byte* args, dd_bool gravity)
{
    uint an;
    int tid, searcher;
    angle_t angle;
    coord_t speed, vspeed;
    mobjtype_t moType;
    mobj_t* mobj, *newMobj;
    dd_bool success;

    success = false;
    searcher = -1;
    tid = args[0];
    moType = TranslateThingType[args[1]];
    if(G_Ruleset_NoMonsters() && (MOBJINFO[moType].flags & MF_COUNTKILL))
    {
        // Don't spawn monsters if -nomonsters
        return false;
    }

    angle = (int) args[2] << 24;
    an = angle >> ANGLETOFINESHIFT;
    speed = FIX2FLT((int) args[3] << 13);
    vspeed = FIX2FLT((int) args[4] << 13);
    while((mobj = P_FindMobjFromTID(tid, &searcher)) != NULL)
    {
        if((newMobj = P_SpawnMobj(moType, mobj->origin, angle, 0)))
        {
            if(newMobj->info->seeSound)
                S_StartSound(newMobj->info->seeSound, newMobj);

            newMobj->target = mobj; // Originator
            newMobj->mom[MX] = speed * FIX2FLT(finecosine[an]);
            newMobj->mom[MY] = speed * FIX2FLT(finesine[an]);
            newMobj->mom[MZ] = vspeed;
            newMobj->flags2 |= MF2_DROPPED; // Don't respawn
            if(gravity == true)
            {
                newMobj->flags &= ~MF_NOGRAVITY;
                newMobj->flags2 |= MF2_LOGRAV;
            }

            if(P_CheckMissileSpawn(newMobj) == true)
            {
                success = true;
            }
        }
    }

    return success;
}
示例#17
0
文件: swf_svg.c 项目: ARSekkat/gpac
static void swf_svg_print_shape_record_to_path_d(SWFReader *read, SWFShapeRec *srec)
{
	u32     pt_idx;
	u32     i;

	pt_idx = 0;
	for (i=0; i<srec->path->nbType; i++) {
		switch (srec->path->types[i]) {
		/*moveTo*/
		case 0:
			swf_svg_print(read, "M%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
			pt_idx++;
			break;
		/*lineTo*/
		case 1:
			swf_svg_print(read, "L%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
			pt_idx++;
			break;
		/*curveTo*/
		case 2:
			swf_svg_print(read, "Q%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
			pt_idx++;
			swf_svg_print(read, ",%g,%g", FIX2FLT(srec->path->pts[pt_idx].x), FIX2FLT(srec->path->pts[pt_idx].y));
			pt_idx++;
			break;
		}
	}
}
示例#18
0
void R_GetWeaponBob(int player, float* x, float* y)
{
    if(x)
    {
        *x = 1 + (cfg.common.bobWeapon * players[player].bob) *
            FIX2FLT(finecosine[(128 * mapTime) & FINEMASK]);
    }

    if(y)
    {
        *y = 32 + (cfg.common.bobWeapon * players[player].bob) *
            FIX2FLT(finesine[(128 * mapTime) & FINEMASK & (FINEANGLES / 2 - 1)]);
    }
}
示例#19
0
static 
GF_Err gdip_set_vertex_center (GF_STENCIL _this, Fixed cx, Fixed cy, u32 color)
{
	GpStatus ret;
	GPSTEN();
	CHECK_RET(GF_STENCIL_VERTEX_GRADIENT);

	if (!_sten->pRadial) return GF_BAD_PARAM;
	_sten->center.X = FIX2FLT(cx);
	_sten->center.Y = FIX2FLT(cy);

	ret = GdipSetPathGradientCenterPoint(_sten->pRadial, &_sten->center);
	ret = GdipSetPathGradientCenterColor(_sten->pRadial, (ARGB) color);
	return GF_OK;
}
示例#20
0
void C_DECL A_Quake(mobj_t* actor)
{
    angle_t angle;
    player_t* player;
    mobj_t* victim;
    int richters = actor->args[0];
    int playnum;
    coord_t dist;

    if(actor->args[1]-- > 0)
    {
        for(playnum = 0; playnum < MAXPLAYERS; ++playnum)
        {
            player = &players[playnum];
            if(!players[playnum].plr->inGame)
                continue;

            victim = player->plr->mo;
            dist =  M_ApproxDistance(actor->origin[VX] - victim->origin[VX],
                                     actor->origin[VY] - victim->origin[VY]);

            dist = FIX2FLT(FLT2FIX(dist) >> (FRACBITS + 6));

            // Tested in tile units (64 pixels).
            if(dist < FIX2FLT(actor->args[3])) // In tremor radius.
            {
                localQuakeHappening[playnum] = richters;
                players[playnum].update |= PSF_LOCAL_QUAKE;
            }

            // Check if in damage radius.
            if(dist < FIX2FLT(actor->args[2]) &&
                    victim->origin[VZ] <= victim->floorZ)
            {
                if(P_Random() < 50)
                {
                    P_DamageMobj(victim, NULL, NULL, HITDICE(1), false);
                }

                // Thrust player around.
                angle = victim->angle + ANGLE_1 * P_Random();
                P_ThrustMobj(victim, angle, FIX2FLT(richters << (FRACBITS - 1)));
            }
        }
    }
    else
    {
        for(playnum = 0; playnum < MAXPLAYERS; playnum++)
示例#21
0
static char *audiobuffer_fetch_frame(void *callback, u32 *size, u32 audio_delay_ms)
{
	u32 blockAlign;
	AudioBufferStack *st = (AudioBufferStack *) gf_node_get_private( ((GF_AudioInput *) callback)->owner);
	M_AudioBuffer *ab = (M_AudioBuffer*)st->output.owner;

	if (!st->is_init) return NULL;
	if (!st->buffer) {
		st->done = 0;
		st->buffer_size = (u32) ceil(FIX2FLT(ab->length) * st->output.input_ifce.bps*st->output.input_ifce.samplerate*st->output.input_ifce.chan/8);
		blockAlign = gf_mixer_get_block_align(st->am);
		/*BLOCK ALIGN*/
		while (st->buffer_size%blockAlign) st->buffer_size++;
		st->buffer = (char*)gf_malloc(sizeof(char) * st->buffer_size);
		memset(st->buffer, 0, sizeof(char) * st->buffer_size);
		st->read_pos = st->write_pos = 0;
	}
	if (st->done) return NULL;

	/*even if not active, fill the buffer*/
	if (st->write_pos < st->buffer_size) {
		u32 written;
		while (1) {
			/*just try to completely fill it*/
			written = gf_mixer_get_output(st->am, st->buffer + st->write_pos, st->buffer_size - st->write_pos, 0);
			if (!written) break;
			st->write_pos += written;
			assert(st->write_pos<=st->buffer_size);
		}
	}
	/*not playing*/
	if (! ab->isActive) return NULL;
	*size = st->write_pos - st->read_pos;
	return st->buffer + st->read_pos;
}
示例#22
0
/*guarentee the tr_state->candidate has the lowest delta value*/
static void group_cache_insert_entry(GF_Node *node, GroupingNode2D *group, GF_TraverseState *tr_state)
{
	u32 i, count;
	GF_List *cache_candidates = tr_state->visual->compositor->cached_groups;
	GroupingNode2D *current;

	current = NULL;
	count = gf_list_count(cache_candidates);
	for (i=0; i<count; i++) {
		current = gf_list_get(cache_candidates, i);
		/*if entry's priority is higher than our group, insert our group here*/
		if (current->priority >= group->priority) {
			gf_list_insert(cache_candidates, group, i);
			break;
		}
	}
	if (i==count)
		gf_list_add(cache_candidates, group);

	tr_state->visual->compositor->video_cache_current_size += group->cached_size;
	/*log the information*/
	GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE]\tAdding object %s\tObjects: %d\tSlope: %g\tSize: %d\tTime: %d\n",
								gf_node_get_log_name(node),
								group->nb_objects,
								FIX2FLT(group->priority),
								group->cached_size,
								group->traverse_time));

	GF_LOG(GF_LOG_DEBUG, GF_LOG_CACHE, ("[CACHE] Status (KB): Max: %d\tUsed: %d\tNb Groups: %d\n",
								tr_state->visual->compositor->video_cache_max_size,
								tr_state->visual->compositor->video_cache_current_size,
								gf_list_count(tr_state->visual->compositor->cached_groups)
								));
}
示例#23
0
static int SV_ReadPlat(plat_t *plat)
{
/* Original Heretic format:
typedef struct {
    thinker_t   thinker;        // was 12 bytes
    Sector     *sector;
    fixed_t     speed;
    fixed_t     low;
    fixed_t     high;
    int         wait;
    int         count;
    platstate_e     status;         // was 32bit int
    platstate_e     oldStatus;      // was 32bit int
    boolean     crush;
    int         tag;
    plattype_e  type;           // was 32bit int
} v13_plat_t;
*/
    byte temp[SIZEOF_V13_THINKER_T];
    // Padding at the start (an old thinker_t struct)
    Reader_Read(svReader, &temp, SIZEOF_V13_THINKER_T);

    // Start of used data members.
    // A 32bit pointer to sector, serialized.
    plat->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader));
    if(!plat->sector)
        Con_Error("tc_plat: bad sector number\n");

    plat->speed = FIX2FLT(Reader_ReadInt32(svReader));
    plat->low = FIX2FLT(Reader_ReadInt32(svReader));
    plat->high = FIX2FLT(Reader_ReadInt32(svReader));
    plat->wait = Reader_ReadInt32(svReader);
    plat->count = Reader_ReadInt32(svReader);
    plat->state = Reader_ReadInt32(svReader);
    plat->oldState = Reader_ReadInt32(svReader);
    plat->crush = Reader_ReadInt32(svReader);
    plat->tag = Reader_ReadInt32(svReader);
    plat->type = Reader_ReadInt32(svReader);

    plat->thinker.function = T_PlatRaise;
    if(!(temp + V13_THINKER_T_FUNC_OFFSET))
        Thinker_SetStasis(&plat->thinker, true);

    P_ToXSector(plat->sector)->specialData = T_PlatRaise;
    return true; // Add this thinker.
}
示例#24
0
void C_DECL A_LeafThrust(mobj_t *actor)
{
    if(P_Random() > 96)
    {
        return;
    }
    actor->mom[MZ] += FIX2FLT(P_Random() << 9) + 1;
}
示例#25
0
static 
GF_Err gdip_set_linear_gradient (GF_STENCIL _this, Fixed start_x, Fixed start_y, Fixed end_x, Fixed end_y)
{
	GPSTEN();
	CHECK_RET(GF_STENCIL_LINEAR_GRADIENT);
	if (_sten->pLinear) GdipDeleteBrush(_sten->pLinear);

	_sten->start.X = FIX2FLT(start_x);
	_sten->start.Y = FIX2FLT(start_y);
	_sten->end.X = FIX2FLT(end_x);
	_sten->end.Y = FIX2FLT(end_y);

	GdipCreateLineBrush(&_sten->start, &_sten->end, 0xFF000000, 0xFFFFFFFF, WrapModeTile, &_sten->pLinear);
	if (!_sten->pLinearMat) GdipCreateMatrix(&_sten->pLinearMat);
	GdipGetLineTransform(_sten->pLinear, _sten->pLinearMat);
	_sten->needs_rebuild = GF_TRUE;
	return GF_OK;
}
示例#26
0
static int SV_ReadFloor(floor_t *floor)
{
/* Original Heretic format:
typedef struct {
    thinker_t   thinker;        // was 12 bytes
    floortype_e type;           // was 32bit int
    boolean     crush;
    Sector     *sector;
    int         direction;
    int         newspecial;
    short       texture;
    fixed_t     floordestheight;
    fixed_t     speed;
} v13_floormove_t;
*/
    Uri *newTextureUrn;

    // Padding at the start (an old thinker_t struct)
    Reader_Read(svReader, NULL, SIZEOF_V13_THINKER_T);

    // Start of used data members.
    floor->type = Reader_ReadInt32(svReader);
    floor->crush = Reader_ReadInt32(svReader);

    // A 32bit pointer to sector, serialized.
    floor->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader));
    if(!floor->sector)
        Con_Error("tc_floor: bad sector number\n");

    floor->state = (int) Reader_ReadInt32(svReader);
    floor->newSpecial = Reader_ReadInt32(svReader);

    newTextureUrn = readTextureUrn(svReader, "Flats");
    floor->material = DD_MaterialForTextureUri(newTextureUrn);
    Uri_Delete(newTextureUrn);

    floor->floorDestHeight = FIX2FLT(Reader_ReadInt32(svReader));
    floor->speed = FIX2FLT(Reader_ReadInt32(svReader));

    floor->thinker.function = T_MoveFloor;

    P_ToXSector(floor->sector)->specialData = T_MoveFloor;
    return true; // Add this thinker.
}
示例#27
0
void P_AnimateSurfaces(void)
{
	int     i;
	line_t *line;

	// Update scrolling textures
	for(i = 0; i < numlinespecials; i++)
	{
		line = linespeciallist[i];
		switch (line->special)
		{
		case 100:				// Scroll_Texture_Left
			sides[line->sidenum[0]].textureoffset += line->arg1 << 10;
			break;
		case 101:				// Scroll_Texture_Right
			sides[line->sidenum[0]].textureoffset -= line->arg1 << 10;
			break;
		case 102:				// Scroll_Texture_Up
			sides[line->sidenum[0]].rowoffset += line->arg1 << 10;
			break;
		case 103:				// Scroll_Texture_Down
			sides[line->sidenum[0]].rowoffset -= line->arg1 << 10;
			break;
		}
	}

	// Update sky column offsets
	Sky1ColumnOffset += Sky1ScrollDelta;
	Sky2ColumnOffset += Sky2ScrollDelta;
	Rend_SkyParams(1, DD_OFFSET, FIX2FLT(Sky1ColumnOffset));
	Rend_SkyParams(0, DD_OFFSET, FIX2FLT(Sky2ColumnOffset));

	if(LevelHasLightning)
	{
		if(!NextLightningFlash || LightningFlash)
		{
			P_LightningFlash();
		}
		else
		{
			NextLightningFlash--;
		}
	}
}
示例#28
0
void C_DECL A_FireMissile(player_t *player, pspdef_t *psp)
{
    P_ShotAmmo(player);
    player->update |= PSF_AMMO;

    if(IS_CLIENT)
        return;

    P_SpawnMissile(MT_ROCKET, player->plr->mo, NULL);

    // jd64 >
    if(cfg.weaponRecoil)
    {
        angle_t         angle = player->plr->mo->angle + ANG180;
        uint            an = angle >> ANGLETOFINESHIFT;

        player->plr->mo->mom[MX] += 4 * FIX2FLT(finecosine[an]);
        player->plr->mo->mom[MY] += 4 * FIX2FLT(finesine[an]);
    }
示例#29
0
static int SV_ReadCeiling(ceiling_t *ceiling)
{
/* Original Heretic format:
typedef struct {
    thinker_t thinker; ///< 12 bytes
    ceilingtype_e type; ///< 32bit int
    Sector* sector;
    fixed_t bottomheight, topheight;
    fixed_t speed;
    boolean crush;
    int direction; /// 1= up, 0= waiting, -1= down
    int tag'
    int olddirection;
} v13_ceiling_t;
*/
    byte temp[SIZEOF_V13_THINKER_T];

    // Padding at the start (an old thinker_t struct)
    Reader_Read(svReader, &temp, SIZEOF_V13_THINKER_T);

    // Start of used data members.
    ceiling->type = Reader_ReadInt32(svReader);

    // A 32bit pointer to sector, serialized.
    ceiling->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader));
    if(!ceiling->sector)
        Con_Error("tc_ceiling: bad sector number\n");

    ceiling->bottomHeight = FIX2FLT(Reader_ReadInt32(svReader));
    ceiling->topHeight    = FIX2FLT(Reader_ReadInt32(svReader));
    ceiling->speed        = FIX2FLT(Reader_ReadInt32(svReader));
    ceiling->crush        = Reader_ReadInt32(svReader);
    ceiling->state        = (Reader_ReadInt32(svReader) == -1? CS_DOWN : CS_UP);
    ceiling->tag          = Reader_ReadInt32(svReader);
    ceiling->oldState     = (Reader_ReadInt32(svReader) == -1? CS_DOWN : CS_UP);

    ceiling->thinker.function = T_MoveCeiling;
    if(!(temp + V13_THINKER_T_FUNC_OFFSET))
        Thinker_SetStasis(&ceiling->thinker, true);

    P_ToXSector(ceiling->sector)->specialData = T_MoveCeiling;
    return true; // Add this thinker.
}
示例#30
0
static GF_Err gdip_get_font_info(GF_FontReader *dr, char **font_name, s32 *em_size, s32 *ascent, s32 *descent, s32 *underline, s32 *line_spacing, s32 *max_advance_h, s32 *max_advance_v)
{
	UINT16 val, em;
	FontPriv *ctx = (FontPriv *)dr->udta;

	*font_name = NULL;
	*em_size = *ascent = *descent = *line_spacing = *max_advance_h = *max_advance_v = 0;
	if (!ctx->font) return GF_BAD_PARAM;

	GdipGetEmHeight(ctx->font, ctx->font_style, &em);
	*em_size = (s32) em;
	GdipGetCellAscent(ctx->font, ctx->font_style, &val);
	ctx->ascent = (Float) val;
	*ascent = (s32) val;
	GdipGetCellDescent(ctx->font, ctx->font_style, &val);
	*descent = (s32) val; *descent *= -1;
	ctx->descent = -1 * (Float) val;
	*underline = *descent / 2;
	GdipGetLineSpacing(ctx->font, ctx->font_style, &val);
	*line_spacing = (s32) val;
	*max_advance_v = *ascent - *descent;


	unsigned short test_str[4];
	Fixed w, h, w2;
	ctx->em_size = (Float) *em_size;
	test_str[0] = (unsigned short) '_';
	test_str[1] = (unsigned short) '\0';
	gdip_get_text_size(dr, test_str, &w, &h);
	ctx->underscore_width = FIX2FLT(w);

	test_str[0] = (unsigned short) '_';
	test_str[1] = (unsigned short) ' ';
	test_str[2] = (unsigned short) '_';
	test_str[3] = (unsigned short) '\0';
	gdip_get_text_size(dr, test_str, &w2, &h);
	ctx->whitespace_width = FIX2FLT(w2 - 2*w);

	*max_advance_h = (s32) MAX(ctx->underscore_width, ctx->whitespace_width);
	return GF_OK;
}