• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Q_rint函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Q_rint函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_rint函数的具体用法?C++ Q_rint怎么用?C++ Q_rint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Q_rint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SnapPlane

void SnapPlane( vec3_t normal, vec_t *dist, vec3_t center )
{
// SnapPlane disabled by LordHavoc because it often messes up collision
// brushes made from triangles of embedded models, and it has little effect
// on anything else (axial planes are usually derived from snapped points)
/*
  SnapPlane reenabled by namespace because of multiple reports of
  q3map2-crashes which were triggered by this patch.
*/
	SnapNormal( normal );

	// TODO: Rambetter has some serious comments here as well.  First off,
	// in the case where a normal is non-axial, there is nothing special
	// about integer distances.  I would think that snapping a distance might
	// make sense for axial normals, but I'm not so sure about snapping
	// non-axial normals.  A shift by 0.01 in a plane, multiplied by a clipping
	// against another plane that is 5 degrees off, and we introduce 0.1 error
	// easily.  A 0.1 error in a vertex is where problems start to happen, such
	// as disappearing triangles.

	// Second, assuming we have snapped the normal above, let's say that the
	// plane we just snapped was defined for some points that are actually
	// quite far away from normal * dist.  Well, snapping the normal in this
	// case means that we've just moved those points by potentially many units!
	// Therefore, if we are going to snap the normal, we need to know the
	// points we're snapping for so that the plane snaps with those points in
	// mind (points remain close to the plane).

	// I would like to know exactly which problems SnapPlane() is trying to
	// solve so that we can better engineer it (I'm not saying that SnapPlane()
	// should be removed altogether).  Fix all this snapping code at some point!

	if( fabs( *dist - Q_rint( *dist ) ) < distanceEpsilon )
		*dist = Q_rint( *dist );
}
开发者ID:clbr,项目名称:netradiant,代码行数:35,代码来源:map.c


示例2: SnapPlane

/*
==============
SnapPlane
==============
*/
void	SnapPlane (vec3_t normal, vec_t *dist)
{
	SnapVector (normal);

	if (fabs(*dist-Q_rint(*dist)) < DIST_EPSILON)
		*dist = Q_rint(*dist);
}
开发者ID:TTimo,项目名称:GtkRadiant,代码行数:12,代码来源:map.c


示例3: SnapPlane

/*
=================
SnapPlane

snaps a plane to normal/distance epsilons
=================
*/
void SnapPlane( vec3_t normal, vec_t *dist )
{
	SnapNormal( normal );

	if( fabs( *dist - Q_rint( *dist )) < distanceEpsilon )
		*dist = Q_rint( *dist );
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:14,代码来源:map.c


示例4: EZ_scrollbar_OnMouseEvent

//
// Scrollbar - Mouse event.
//
int EZ_scrollbar_OnMouseEvent(ez_control_t *self, mouse_state_t *ms)
{
	ez_scrollbar_t *scrollbar		= (ez_scrollbar_t *)self;
	ez_control_t *back_ctrl			= (ez_control_t *)scrollbar->back;
	ez_control_t *forward_ctrl		= (ez_control_t *)scrollbar->forward;
	ez_control_t *slider_ctrl		= (ez_control_t *)scrollbar->slider;
	int m_delta_x					= Q_rint(ms->x - ms->x_old);
	int m_delta_y					= Q_rint(ms->y - ms->y_old);
	qbool mouse_handled				= false;
	qbool mouse_handled_tmp			= false;

	mouse_handled = EZ_control_OnMouseEvent(self, ms);

	if (!mouse_handled)
	{
		if (scrollbar->int_flags & sliding)
		{
			if (scrollbar->orientation == vertical)
			{
//				float scroll_ratio = 0;

				// Reposition the slider within the scrollbar control based on where the mouse moves.
				int new_y = slider_ctrl->y + m_delta_y;

				// Only allow moving the scroll slider in the area between the two buttons (the scroll area).
				clamp(new_y, back_ctrl->height, (self->height - forward_ctrl->height - slider_ctrl->height));
				EZ_control_SetPosition(slider_ctrl, 0, new_y);

				mouse_handled = true;
			}
			else
			{
				int new_x = slider_ctrl->x + m_delta_x;
				clamp(new_x, back_ctrl->width, (self->width - forward_ctrl->width - slider_ctrl->width));
				EZ_control_SetPosition(slider_ctrl, new_x, 0);
				mouse_handled = true;
			}

			// Make sure we don't try to set the position of the slider
			// as the parents scroll position changes, like normal.
			scrollbar->int_flags |= scrolling;

			if (scrollbar->ext_flags & target_parent)
			{
				EZ_scrollbar_CalculateParentScrollPosition(scrollbar, self->parent);
			}
			else
			{
				EZ_scrollbar_CalculateParentScrollPosition(scrollbar, scrollbar->target);
			}
			
			scrollbar->int_flags &= ~scrolling;
		}
	}

	CONTROL_EVENT_HANDLER_CALL(&mouse_handled_tmp, self, ez_control_t, OnMouseEvent, ms);
	mouse_handled = (mouse_handled | mouse_handled_tmp);

	return mouse_handled;
}
开发者ID:AAS,项目名称:ezquake-source,代码行数:63,代码来源:ez_scrollbar.c


示例5: WriteFloat

void WriteFloat (FILE *f, vec_t v)
{
	if ( fabs(v - Q_rint(v)) < 0.001 )
		fprintf (f,"%i ",(int)Q_rint(v));
	else
		fprintf (f,"%f ",v);
}
开发者ID:ChunHungLiu,项目名称:GtkRadiant,代码行数:7,代码来源:prtfile.c


示例6: WriteFloat

static void
WriteFloat(vec_t v)
{
    if (fabs(v - Q_rint(v)) < ZERO_EPSILON)
	fprintf(PortalFile, "%i ", (int)Q_rint(v));
    else
	fprintf(PortalFile, "%f ", v);
}
开发者ID:AidHamza,项目名称:eviltoys,代码行数:8,代码来源:portals.c


示例7: Cvar_SetValue

/*
* Cvar_SetValue
* Expands value to a string and calls Cvar_Set
*/
void Cvar_SetValue( const char *var_name, float value )
{
	char val[32];
	if( value == Q_rint( value ) )
		Q_snprintfz( val, sizeof( val ), "%i", Q_rint( value ) );
	else
		Q_snprintfz( val, sizeof( val ), "%f", value );
	Cvar_Set( var_name, val );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:13,代码来源:cvar.c


示例8: EZ_slider_OnDraw

//
// Slider - Draw function for the slider.
//
int EZ_slider_OnDraw(ez_control_t *self, void *ext_event_info)
{
	int x, y, i;
	ez_slider_t *slider = (ez_slider_t *)self;

	EZ_control_GetDrawingPosition(self, &x, &y);

	// Draw the background.
	{
		// Left edge.
		Draw_SCharacter(x, y, 128, slider->scale);

		for (i = 1; i < Q_rint((float)(self->width - slider->scaled_char_size) / slider->scaled_char_size); i++)
		{
			Draw_SCharacter(x + (i * slider->scaled_char_size), y, 129, slider->scale);
		}

		// Right edge.
		Draw_SCharacter(x + (i * slider->scaled_char_size), y, 130, slider->scale);
	}

	// Slider.
	Draw_SCharacter(x + slider->real_slider_pos, y, 131, slider->scale);

	return 0;
}
开发者ID:AAS,项目名称:ezquake-source,代码行数:29,代码来源:ez_slider.c


示例9:

/*
=============
Fog_GetColor

calculates fog color for this frame, taking into account fade times
=============
*/
float *Fog_GetColor (void)
{
	static float c[4];
	float f;
	int i;

	if (fade_done > cl.time)
	{
		f = (fade_done - cl.time) / fade_time;
		c[0] = f * old_red + (1.0 - f) * fog_red;
		c[1] = f * old_green + (1.0 - f) * fog_green;
		c[2] = f * old_blue + (1.0 - f) * fog_blue;
		c[3] = 1.0;
	}
	else
	{
		c[0] = fog_red;
		c[1] = fog_green;
		c[2] = fog_blue;
		c[3] = 1.0;
	}

	//find closest 24-bit RGB value, so solid-colored sky can match the fog perfectly
	for (i=0;i<3;i++)
		c[i] = (float)(Q_rint(c[i] * 255)) / 255.0f;

	return c;
}
开发者ID:ACIIL,项目名称:Quakespasm-Rift,代码行数:35,代码来源:gl_fog.c


示例10: SnapPlaneImproved

/*
SnapPlaneImproved()
snaps a plane to normal/distance epsilons, improved code
*/
void SnapPlaneImproved(vec3_t normal, vec_t *dist, int numPoints, const vec3_t *points)
{
	int	i;
	vec3_t	center;
	vec_t	distNearestInt;

	if (SnapNormal(normal))
	{
		if (numPoints > 0)
		{
			// Adjust the dist so that the provided points don't drift away.
			VectorClear(center);
			for (i = 0; i < numPoints; i++)
			{
				VectorAdd(center, points[i], center);
			}
			for (i = 0; i < 3; i++) { center[i] = center[i] / numPoints; }
			*dist = DotProduct(normal, center);
		}
	}

	if (VectorIsOnAxis(normal))
	{
		// Only snap distance if the normal is an axis.  Otherwise there
		// is nothing "natural" about snapping the distance to an integer.
		distNearestInt = Q_rint(*dist);
		if (-distanceEpsilon < *dist - distNearestInt && *dist - distNearestInt < distanceEpsilon)
		{
			*dist = distNearestInt;
		}
	}
}
开发者ID:clbr,项目名称:netradiant,代码行数:36,代码来源:map.c


示例11: EZ_slider_OnMouseEvent

//
// Slider - Handles a mouse event.
//
int EZ_slider_OnMouseEvent(ez_control_t *self, mouse_state_t *ms)
{
	// Make sure we handle all mouse events when we're over the control
	// otherwise they will fall through to controls below.
	int mouse_handled	= POINT_IN_CONTROL_RECT(self, ms->x, ms->y); 
	ez_slider_t *slider = (ez_slider_t *)self;

	// Call the super class first.
	EZ_control_OnMouseEvent(self, ms);
	
	if (slider->int_flags & slider_dragging)
	{
		int new_slider_pos = slider->min_value + Q_rint((ms->x - self->absolute_x) / slider->gap_size);
		EZ_slider_SetPosition(slider, new_slider_pos);
		mouse_handled = true;
	}
	
	// Event handler call.
	{
		int mouse_handled_tmp = false;
		CONTROL_EVENT_HANDLER_CALL(&mouse_handled_tmp, self, ez_control_t, OnMouseEvent, ms);
		mouse_handled = (mouse_handled || mouse_handled_tmp);
	}

	return mouse_handled;
}
开发者ID:AAS,项目名称:ezquake-source,代码行数:29,代码来源:ez_slider.c


示例12: Cvar_GetLatchedVars

/*
* Cvar_GetLatchedVars
* 
* Any variables with CVAR_LATCHED will now be updated
*/
void Cvar_GetLatchedVars( cvar_flag_t flags )
{
	unsigned int i;
	struct trie_dump_s *dump;
	cvar_flag_t latchFlags;

	Cvar_FlagsClear( &latchFlags );
	Cvar_FlagSet( &latchFlags, CVAR_LATCH );
	Cvar_FlagSet( &latchFlags, CVAR_LATCH_VIDEO );
	Cvar_FlagSet( &latchFlags, CVAR_LATCH_SOUND );
	Cvar_FlagUnset( &flags, ~latchFlags );
	if( !flags )
		return;

	assert( cvar_trie );
	Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_IsLatched, &flags, &dump );
	for( i = 0; i < dump->size; ++i )
	{
		cvar_t *const var = (cvar_t *) dump->key_value_vector[i].value;
		if( !strcmp( var->name, "fs_game" ) )
		{
			FS_SetGameDirectory( var->latched_string, qfalse );
			return;
		}
		Mem_ZoneFree( var->string );
		var->string = var->latched_string;
		var->latched_string = NULL;
		var->value = atof( var->string );
		var->integer = Q_rint( var->value );
	}
	Trie_FreeDump( dump );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:37,代码来源:cvar.c


示例13: GetVertex

/*
=============
GetVertex
=============
*/
static int
GetVertex(mapentity_t *entity, const vec3_t in)
{
    int h;
    int i;
    hashvert_t *hv;
    vec3_t vert;
    struct lumpdata *vertices = &entity->lumps[LUMP_VERTEXES];
    dvertex_t *dvertex;

    for (i = 0; i < 3; i++) {
        if (fabs(in[i] - Q_rint(in[i])) < ZERO_EPSILON)
            vert[i] = Q_rint(in[i]);
        else
            vert[i] = in[i];
    }

    h = HashVec(vert);
    for (hv = hashverts[h]; hv; hv = hv->next) {
        if (fabs(hv->point[0] - vert[0]) < POINT_EPSILON &&
            fabs(hv->point[1] - vert[1]) < POINT_EPSILON &&
            fabs(hv->point[2] - vert[2]) < POINT_EPSILON) {
            hv->numedges++;
            return hv->num;
        }
    }

    hv = hvert_p++;
    hv->num = map.cTotal[LUMP_VERTEXES]++;
    hv->numedges = 1;
    hv->next = hashverts[h];
    hashverts[h] = hv;
    VectorCopy(vert, hv->point);

    if (vertices->index == vertices->count)
        Error("Internal error: didn't allocate enough vertices?");

    /* emit a vertex */
    dvertex = (dvertex_t *)vertices->data + vertices->index;
    dvertex->point[0] = vert[0];
    dvertex->point[1] = vert[1];
    dvertex->point[2] = vert[2];
    vertices->index++;

    return hv->num;
}
开发者ID:kduske,项目名称:tyrutils-ericw,代码行数:51,代码来源:surfaces.c


示例14: EZ_slider_CalculateRealSliderPos

//
// Slider - Calculates the actual slider position.
//
__inline void EZ_slider_CalculateRealSliderPos(ez_slider_t *slider)
{
	int pos = slider->slider_pos - slider->min_value;

	// Calculate the real position of the slider by multiplying by the gap size between each value.
	// (Don't start drawing at the exact start cause that would overwrite the edge marker)
	slider->real_slider_pos = Q_rint((slider->scaled_char_size / 2.0) + (pos * slider->gap_size));
}
开发者ID:AAS,项目名称:ezquake-source,代码行数:11,代码来源:ez_slider.c


示例15: Movie_GetSoundtime

qboolean Movie_GetSoundtime (void)
{
    if (!Movie_IsActive())
        return false;

    soundtime += Q_rint (host_frametime * shm->speed * (Movie_FrameTime() / host_frametime));

    return true;
}
开发者ID:dommul,项目名称:super8,代码行数:9,代码来源:movie.c


示例16: EZ_scrollbar_UpdateSliderBasedOnTarget

//
// Scrollbar - Updates the slider position of the scrollbar based on the parents scroll position.
//
static void EZ_scrollbar_UpdateSliderBasedOnTarget(ez_scrollbar_t *scrollbar, ez_control_t *target)
{
	ez_control_t *self			= (ez_control_t *)scrollbar;
	ez_control_t *back_ctrl		= (ez_control_t *)scrollbar->back;
	ez_control_t *forward_ctrl	= (ez_control_t *)scrollbar->forward;
	ez_control_t *slider_ctrl	= (ez_control_t *)scrollbar->slider;
	float scroll_ratio;

	if (!target)
	{
		return;
	}

	// Don't do anything if this is the user moving the slider using the mouse.
	if (scrollbar->int_flags & scrolling)
	{
		return;
	}

	if (scrollbar->orientation == vertical)
	{
		int new_y;

		// Find how far down on the parent control we're scrolled (percentage).
		scroll_ratio = fabs(target->virtual_y / (float)target->virtual_height);
		
		// Calculate the position of the slider by multiplying the scroll areas
		// height with the scroll ratio.
		new_y = back_ctrl->height + Q_rint(scroll_ratio * scrollbar->scroll_area);
		clamp(new_y, back_ctrl->height, (self->height - forward_ctrl->height - slider_ctrl->height));

		EZ_control_SetPosition(slider_ctrl, 0, new_y);
	}
	else
	{
		int new_x;
		scroll_ratio = fabs(target->virtual_x / (float)target->virtual_width);
		
		new_x = back_ctrl->width + Q_rint(scroll_ratio * scrollbar->scroll_area);
		clamp(new_x, back_ctrl->width, (self->width - forward_ctrl->width - slider_ctrl->width));
		
		EZ_control_SetPosition(slider_ctrl, new_x, 0);
	}
}
开发者ID:AAS,项目名称:ezquake-source,代码行数:47,代码来源:ez_scrollbar.c


示例17: WriteFloatToPortalFile

// Vic: proper float output
static void WriteFloatToPortalFile (vec_t f)
{
	int i;

	i = Q_rint(f);
	if( f == i )
		fprintf( pf, "%i", i );
	else
		fprintf( pf, "%f", f );
}
开发者ID:Acidburn0zzz,项目名称:KatanaEngine,代码行数:11,代码来源:level_portals.c


示例18: GetVertexnum

/**
 * @brief Returns the number of an existing vertex or allocates a new one
 * @note Uses hashing
 */
static int GetVertexnum (const vec3_t in)
{
	vec3_t vert;

	c_totalverts++;

	for (int i = 0; i < 3; i++) {
		if (fabs(in[i] - Q_rint(in[i])) < INTEGRAL_EPSILON)
			vert[i] = Q_rint(in[i]);
		else
			vert[i] = in[i];
	}

	int h = HashVec(vert);

	for (int vnum = hashverts[h]; vnum; vnum = vertexchain[vnum]) {
		const float* p = curTile->vertexes[vnum].point;
		if (fabs(p[0] - vert[0]) < POINT_EPSILON
		 && fabs(p[1] - vert[1]) < POINT_EPSILON
		 && fabs(p[2] - vert[2]) < POINT_EPSILON)
			return vnum;
	}

	/* emit a vertex */
	if (curTile->numvertexes == MAX_MAP_VERTS)
		Sys_Error("numvertexes == MAX_MAP_VERTS");

	curTile->vertexes[curTile->numvertexes].point[0] = vert[0];
	curTile->vertexes[curTile->numvertexes].point[1] = vert[1];
	curTile->vertexes[curTile->numvertexes].point[2] = vert[2];

	vertexchain[curTile->numvertexes] = hashverts[h];
	hashverts[h] = curTile->numvertexes;

	c_uniqueverts++;

	curTile->numvertexes++;
	curTile->numnormals++;

	return curTile->numvertexes - 1;
}
开发者ID:ArkyRomania,项目名称:ufoai,代码行数:45,代码来源:faces.cpp


示例19: SnapWeldVector

void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out ){
	int i;
	vec_t ai, bi, outi;


	/* dummy check */
	if ( a == NULL || b == NULL || out == NULL ) {
		return;
	}

	/* do each element */
	for ( i = 0; i < 3; i++ )
	{
		/* round to integer */
		ai = Q_rint( a[ i ] );
		bi = Q_rint( b[ i ] );

		/* prefer exact integer */
		if ( ai == a[ i ] ) {
			out[ i ] = a[ i ];
		}
		else if ( bi == b[ i ] ) {
			out[ i ] = b[ i ];
		}

		/* use nearest */
		else if ( fabs( ai - a[ i ] ) < fabs( bi - b[ i ] ) ) {
			out[ i ] = a[ i ];
		}
		else{
			out[ i ] = b[ i ];
		}

		/* snap */
		outi = Q_rint( out[ i ] );
		if ( fabs( outi - out[ i ] ) <= SNAP_EPSILON ) {
			out[ i ] = outi;
		}
	}
}
开发者ID:xonotic,项目名称:netradient,代码行数:40,代码来源:brush.c


示例20: EZ_scrollbar_CalculateSliderSize

//
// Scrollbar - Calculates the size of the slider button.
//
static void EZ_scrollbar_CalculateSliderSize(ez_scrollbar_t *scrollbar, ez_control_t *target)
{
	ez_control_t *self = (ez_control_t *)scrollbar;

	if (target)
	{
		if (scrollbar->orientation == vertical)
		{
			// Get the percentage of the parent that is shown and calculate the new slider button size from that. 
			float target_height_ratio	= (target->height / (float)target->virtual_height);
			int new_slider_height		= max(scrollbar->slider_minsize, Q_rint(target_height_ratio * scrollbar->scroll_area));

			EZ_control_SetSize((ez_control_t *)scrollbar->slider, self->width, new_slider_height);
		}
		else
		{
			float target_width_ratio	= (target->width / (float)target->virtual_width);
			int new_slider_width		= max(scrollbar->slider_minsize, Q_rint(target_width_ratio * scrollbar->scroll_area));

			EZ_control_SetSize((ez_control_t *)scrollbar->slider, new_slider_width, self->height);
		}
	}
}
开发者ID:AAS,项目名称:ezquake-source,代码行数:26,代码来源:ez_scrollbar.c



注:本文中的Q_rint函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Q_snprintf函数代码示例发布时间:2022-05-30
下一篇:
C++ Q_memset函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap