Ejemplo n.º 1
0
void CUIActorMenu::UpdateConditionProgressBars()
{
	PIItem itm = m_pActorInvOwner->inventory().ItemFromSlot(INV_SLOT_2);
	if(itm)
	{
		m_WeaponSlot1_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	}
	else
		m_WeaponSlot1_progress->SetProgressPos(0);

	itm = m_pActorInvOwner->inventory().ItemFromSlot(INV_SLOT_3);
	if(itm)
		m_WeaponSlot2_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	else
		m_WeaponSlot2_progress->SetProgressPos(0);

	itm = m_pActorInvOwner->inventory().ItemFromSlot(OUTFIT_SLOT);
	if(itm)
		m_Outfit_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	else
		m_Outfit_progress->SetProgressPos(0);

	itm = m_pActorInvOwner->inventory().ItemFromSlot(HELMET_SLOT);
	if(itm)
		m_Helmet_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	else
		m_Helmet_progress->SetProgressPos(0);
}
Ejemplo n.º 2
0
void	CRenderTarget::u_calc_tc_noise		(Fvector2& p0, Fvector2& p1)
{
	CTexture*	T					= RCache.get_ActiveTexture	(2);
	VERIFY2		(T, "Texture #3 in noise shader should be setted up");
	u32			tw					= iCeil(float(T->get_Width	())*param_noise_scale+EPS_S);
	u32			th					= iCeil(float(T->get_Height ())*param_noise_scale+EPS_S);
	VERIFY2		(tw && th, "Noise scale can't be zero in any way");

	// calculate shift from FPSes
	im_noise_time					-= Device.fTimeDelta;
	if (im_noise_time<0)			{
		im_noise_shift_w			= ::Random.randI(tw?tw:1);
		im_noise_shift_h			= ::Random.randI(th?th:1);
		float	fps_time			= 1/param_noise_fps;
		while (im_noise_time<0)		im_noise_time += fps_time;
	}

	u32			shift_w				= im_noise_shift_w;
	u32			shift_h				= im_noise_shift_h;
	float		start_u				= (float(shift_w)+.5f)/(tw);
	float		start_v				= (float(shift_h)+.5f)/(th);
	u32			_w					= Device.dwWidth;
	u32			_h					= Device.dwHeight;
	u32			cnt_w				= _w / tw;
	u32			cnt_h				= _h / th;
	float		end_u				= start_u + float(cnt_w) + 1;
	float		end_v				= start_v + float(cnt_h) + 1;
 
	p0.set		(start_u,	start_v	);
	p1.set		(end_u,		end_v	);
}
Ejemplo n.º 3
0
void CUIFrameLineWnd::DrawElements()
{
	UIRender->SetShader			(*m_shader);

	Fvector2					ts;
	UIRender->GetActiveTextureResolution(ts);

	Frect						rect;
	GetAbsoluteRect				(rect);
	UI().ClientToScreenScaled	(rect.lt);
	UI().ClientToScreenScaled	(rect.rb);
	
	float back_len				= 0.0f;
	u32 prim_count				= 6*2; //first&second 
	if(bHorizontal)
	{
		back_len				= rect.width()-m_tex_rect[flFirst].width()-m_tex_rect[flSecond].width();
		if(back_len<0.0f)
			rect.x2				-= back_len;

		if(back_len>0.0f)
			prim_count				+= 6* iCeil(back_len / m_tex_rect[flBack].width());
	}else
	{
		back_len				= rect.height()-m_tex_rect[flFirst].height()-m_tex_rect[flSecond].height();
		if(back_len<0)
			rect.y2				-= back_len;

		if(back_len>0.0f)
			prim_count				+= 6* iCeil(back_len / m_tex_rect[flBack].height());
	}

	UIRender->StartPrimitive	(prim_count, IUIRender::ptTriList, UI().m_currentPointType);

	for(int i=0; i<flMax; ++i)
	{
		Fvector2 LTt, RBt;
		Fvector2 LTp, RBp;
		int counter				= 0;

		while(inc_pos(rect, counter, i, LTp, RBp, LTt, RBt))
		{
			draw_rect				(LTp, RBp, LTt, RBt, m_texture_color, ts);
			++counter;
		};
	}
	UIRender->FlushPrimitive		();
}
Ejemplo n.º 4
0
void CUICellItem::UpdateConditionProgressBar()
{

	if(m_pParentList && m_pParentList->GetConditionProgBarVisibility())
	{
		PIItem itm = (PIItem)m_pData;
		CWeapon* pWeapon = smart_cast<CWeapon*>(itm);
		CCustomOutfit* pOutfit = smart_cast<CCustomOutfit*>(itm);
		CHelmet* pHelmet = smart_cast<CHelmet*>(itm);
		if(pWeapon || pOutfit || pHelmet)
		{
			Ivector2 itm_grid_size = GetGridSize();
			if(m_pParentList->GetVerticalPlacement())
				std::swap(itm_grid_size.x, itm_grid_size.y);

			Ivector2 cell_size = m_pParentList->CellSize();
			Ivector2 cell_space = m_pParentList->CellsSpacing();
			float x = 1.f;
			float y = itm_grid_size.y * (cell_size.y + cell_space.y) - m_pConditionState->GetHeight() - 2.f;

			m_pConditionState->SetWndPos(Fvector2().set(x,y));
			m_pConditionState->SetProgressPos(iCeil(itm->GetCondition()*13.0f)/13.0f);
			m_pConditionState->Show(true);
			return;
		}
	}
	m_pConditionState->Show(false);
}
Ejemplo n.º 5
0
Vector2 GFont::appendToCharVertexArrayWordWrap
(Array<CPUCharVertex>&       cpuCharArray,
 Array<int>&                 indexArray,
 RenderDevice*               renderDevice,
 float                       maxWidth,
 const String&               s,
 const Vector2&              pos2D,
 float                       size,
 const Color4&               color,
 const Color4&               border,
 XAlign                      xalign,
 YAlign                      yalign,
 Spacing                     spacing) const {

    if (maxWidth == finf()) {
        return appendToCharVertexArray(cpuCharArray, indexArray, renderDevice, s, pos2D, size, color, border, xalign, yalign, spacing);
    }

    Vector2 bounds = Vector2::zero();
    Point2 p = pos2D;
    String rest = s;
    String first = "";

    while (! rest.empty()) {
        wordWrapCut(maxWidth, rest, first, size, spacing);
        Vector2 extent = appendToCharVertexArray(cpuCharArray, indexArray, renderDevice, first, p, size, color, border, xalign, yalign, spacing);
        bounds.x = max(bounds.x, extent.x);
        bounds.y += extent.y;
        p.y += iCeil(extent.y * 0.8f);
    }

    return bounds;
}
Ejemplo n.º 6
0
std::string vformat(const char *fmt, va_list argPtr) {
    // We draw the line at a 1MB string.
    const int maxSize = 1000000;

    // If the string is less than 161 characters,
    // allocate it on the stack because this saves
    // the malloc/free time.
    const int bufSize = 161;
    char stackBuffer[bufSize];

    int actualWritten = vsnprintf(stackBuffer, bufSize, fmt, argPtr);

    // Not a big enough buffer, bufSize characters written
    if (actualWritten == -1) {
        int heapSize = 512;
        double powSize = 1.0;
        char* heapBuffer = (char*)System::malloc(heapSize);

        while ((vsnprintf(heapBuffer, heapSize, fmt, argPtr) == -1) &&
            (heapSize  < maxSize)) {
            heapSize = iCeil(heapSize * ::pow((double)2.0, powSize++));
            heapBuffer = (char*)System::realloc(heapBuffer, heapSize);
        }

        heapBuffer[heapSize-1] = '\0';

        std::string heapString(heapBuffer);
        System::free(heapBuffer);

        return heapString;
    } else {
        return std::string(stackBuffer);
    }
}
Ejemplo n.º 7
0
void DepthOfField::blurPass
(RenderDevice*                  rd,
 const shared_ptr<Texture>&     input,
 const shared_ptr<Framebuffer>& output,
 shared_ptr<Shader>             shader,
 const shared_ptr<Camera>&      camera) {

    const float dimension = float((camera->fieldOfViewDirection() == FOVDirection::HORIZONTAL) ? input->width() : input->height());

    alwaysAssertM(input, "input is NULL");

    const float maxRadiusFraction =
        max(camera->depthOfFieldSettings().nearBlurRadiusFraction(), camera->depthOfFieldSettings().farBlurRadiusFraction());

    const int maxCoCRadiusPixels =
        iCeil((camera->depthOfFieldSettings().model() == DepthOfFieldModel::ARTIST) ?
              (maxRadiusFraction * dimension) :
              maxPhysicalBlurRadius(camera, m_packedBuffer->rect2DBounds()));

    rd->push2D(output);
    {
        rd->clear();

        Args args;

        args.setUniform("blurSourceBuffer",   input);
        args.setUniform("maxCoCRadiusPixels", maxCoCRadiusPixels);
        args.setRect(rd->viewport());
        LAUNCH_SHADER_PTR(shader, args);
    }
    rd->pop2D();
}
Ejemplo n.º 8
0
IC int PLC_calc	(Fvector& P, Fvector& N, light* L, float energy, Fvector& O)
{
	float	E		= PLC_energy(P,N,L,energy);
	float	C1		= clampr(Device.vCameraPosition.distance_to_sqr(P)/S_distance2,	0.f,1.f);
	float	C2		= clampr(O.distance_to_sqr(P)/S_fade2,							0.f,1.f);
	float	A		= 1.f-1.5f*E*(1.f-C1)*(1.f-C2);
	return			iCeil(255.f*A);
}
Ejemplo n.º 9
0
u32 CPHWorld::CalcNumSteps (u32 dTime)
{
	if (dTime < m_frame_time*1000) return 0;
	u32 res = iCeil((float(dTime) - m_frame_time*1000) / (fixed_step*1000));
//	if (dTime < fixed_step*1000) return 0;
//	u32 res = iFloor((float(dTime) / 1000 / fixed_step)+0.5f);
	return res;
};
Ejemplo n.º 10
0
/*
void CSheduler::Switch				()
{
	if (fibered)	
	{
		fibered						= FALSE;
		SwitchToFiber				(fiber_main);
	}
}
*/
void CSheduler::Update				()
{
	R_ASSERT						(Device.Statistic);
	// Initialize
	Device.Statistic->Sheduler.Begin();
	cycles_start					= CPU::QPC			();
	cycles_limit					= CPU::qpc_freq * u64 (iCeil(psShedulerCurrent)) / 1000i64 + cycles_start;
	internal_Registration			();
	g_bSheduleInProgress			= TRUE;

#ifdef DEBUG_SCHEDULER
	Msg								("SCHEDULER: PROCESS STEP %d",Device.dwFrame);
#endif // DEBUG_SCHEDULER
	// Realtime priority
	m_processing_now				= true;
	u32	dwTime						= Device.dwTimeGlobal;
	for (u32 it=0; it<ItemsRT.size(); it++)
	{
		Item&	T					= ItemsRT[it];
		R_ASSERT					(T.Object);
#ifdef DEBUG_SCHEDULER
		Msg							("SCHEDULER: process step [%s][%x][true]",*T.Object->shedule_Name(),T.Object);
#endif // DEBUG_SCHEDULER
		if(!T.Object->shedule_Needed()){
#ifdef DEBUG_SCHEDULER
			Msg						("SCHEDULER: process unregister [%s][%x][%s]",*T.Object->shedule_Name(),T.Object,"false");
#endif // DEBUG_SCHEDULER
			T.dwTimeOfLastExecute	= dwTime;
			continue;
		}

		u32	Elapsed					= dwTime-T.dwTimeOfLastExecute;
#ifdef DEBUG
		VERIFY						(T.Object->dbg_startframe != Device.dwFrame);
		T.Object->dbg_startframe	= Device.dwFrame;
#endif
		T.Object->shedule_Update	(Elapsed);
		T.dwTimeOfLastExecute		= dwTime;
	}

	// Normal (sheduled)
	ProcessStep						();
	m_processing_now				= false;
#ifdef DEBUG_SCHEDULER
	Msg								("SCHEDULER: PROCESS STEP FINISHED %d",Device.dwFrame);
#endif // DEBUG_SCHEDULER
	clamp							(psShedulerTarget,3.f,66.f);
	psShedulerCurrent				= 0.9f*psShedulerCurrent + 0.1f*psShedulerTarget;
	Device.Statistic->fShedulerLoad	= psShedulerCurrent;

	// Finalize
	g_bSheduleInProgress			= FALSE;
	internal_Registration			();
	Device.Statistic->Sheduler.End	();
}
Ejemplo n.º 11
0
void CDeflector::L_Direct_Edge (CDB::COLLIDER* DB, base_lighting* LightsSelected, Fvector2& p1, Fvector2& p2, Fvector& v1, Fvector& v2, Fvector& N, float texel_size, Face* skip)
{
	Fvector		vdir;
	vdir.sub	(v2,v1);
	
	lm_layer&	lm	= layer;
	
	Fvector2		size; 
	size.x			= p2.x-p1.x;
	size.y			= p2.y-p1.y;
	int	du			= iCeil(_abs(size.x)/texel_size);
	int	dv			= iCeil(_abs(size.y)/texel_size);
	int steps		= _max(du,dv);
	if (steps<=0)	return;
	
	for (int I=0; I<=steps; I++)
	{
		float	time = float(I)/float(steps);
		Fvector2	uv;
		uv.x	= size.x*time+p1.x;
		uv.y	= size.y*time+p1.y;
		int	_x  = iFloor(uv.x*float(lm.width)); 
		int _y	= iFloor(uv.y*float(lm.height));
		
		if ((_x<0)||(_x>=(int)lm.width))	continue;
		if ((_y<0)||(_y>=(int)lm.height))	continue;
		
		if (lm.marker[_y*lm.width+_x])		continue;
		
		// ok - perform lighting
		base_color_c	C;
		Fvector			P;	P.mad(v1,vdir,time);
		LightPoint		(DB, RCAST_Model, C, P, N, *LightsSelected, (b_norgb?LP_dont_rgb:0)|(b_nosun?LP_dont_sun:0)|LP_DEFAULT, skip); //.
		
		C.mul		(.5f);
		lm.surface	[_y*lm.width+_x]._set	(C);
		lm.marker	[_y*lm.width+_x]		= 255;
	}
}
Ejemplo n.º 12
0
void InternalRender()
{
	Fvector S,P;
	LevelBB.getsize(S);
	dimX	= iCeil(S.x/g_params.fPatchSize);
	dimZ	= iCeil(S.z/g_params.fPatchSize);

	// allocation
	int		msize = dimX*dimZ*sizeof(Texel);
	texels	= (Texel*)xr_malloc(msize);
	ZeroMemory(texels,msize);

	// rasterization
	for (u32 i=0; i<g_nodes.size(); i++)
	{
		vertex&	N	= g_nodes[i];
		P.sub	(N.Pos, LevelBB.min);
		int		nx	= iFloor(P.x/g_params.fPatchSize+0.5f);	clamp(nx,0,dimX-1);
		int		nz	= iFloor(P.z/g_params.fPatchSize+0.5f);	clamp(nz,0,dimZ-1);

		Texel&	T	= texels[(dimZ-nz-1)*dimX+nx];
		T.depth++;
		if (T.N)	{ if (N.Pos.y>T.N->Pos.y)	T.N = &N; }
		else		T.N = &N;
	}

	// limits
	for (int t=0; t<dimX*dimZ; t++)
	{
		Texel& T	= texels[t];
		if (T.N)	{
			minH		= _min(minH,T.N->Pos.y);
			maxH		= _max(maxH,T.N->Pos.y);
		}
	}
}
Ejemplo n.º 13
0
void		CLevel::UpdateDeltaUpd	( u32 LastTime )
{
	u32 CurrentDelta = LastTime - m_dwLastNetUpdateTime;
	if (CurrentDelta < m_dwDeltaUpdate) 
		CurrentDelta = iFloor(float(m_dwDeltaUpdate * 10 + CurrentDelta) / 11);

	m_dwLastNetUpdateTime = LastTime;
	m_dwDeltaUpdate = CurrentDelta;

	if (0 == g_cl_lvInterp) ReculcInterpolationSteps();
	else 
		if (g_cl_lvInterp>0)
		{
			lvInterpSteps = iCeil(g_cl_lvInterp / fixed_step);
		}
};
Ejemplo n.º 14
0
void BinaryOutput::compress(int level) {
    if (m_alreadyWritten > 0) {
        throw "Cannot compress huge files (part of this file has already been written to disk).";
    }
    debugAssertM(! m_committed, "Cannot compress after committing.");
    alwaysAssertM(m_bufferLen < 0xFFFFFFFF, "Compress only works for 32-bit files.");

    // This is the worst-case size, as mandated by zlib
    unsigned long compressedSize = iCeil(m_bufferLen * 1.001) + 12;

    // Save the old buffer and reallocate to the worst-case size
    const uint8* src     = m_buffer;
    const uint32 srcSize = (uint32)m_bufferLen;

    // add space for the 4-byte header
    m_maxBufferLen = compressedSize + 4;
    m_buffer = (uint8*)System::malloc(m_maxBufferLen);
    
    // Write the header containing the old buffer size, which is needed for decompression
    {
        const uint8* convert = (const uint8*)&srcSize;
        if (m_swapBytes) {
            m_buffer[0] = convert[3];
            m_buffer[1] = convert[2];
            m_buffer[2] = convert[1];
            m_buffer[3] = convert[0];
        } else {
            m_buffer[0] = convert[0];
            m_buffer[1] = convert[1];
            m_buffer[2] = convert[2];
            m_buffer[3] = convert[3];
        }
    }

    // Compress and write after the header
    int result = compress2(m_buffer + 4, &compressedSize, src, srcSize, iClamp(level, 0, 9));

    debugAssert(result == Z_OK); (void)result;
    m_bufferLen = compressedSize + 4;
    m_pos = m_bufferLen;

    // Free the old data
    System::free((void*)src);
}
Ejemplo n.º 15
0
void BinaryOutput::compress() {
    if (m_alreadyWritten > 0) {
        throw "Cannot compress huge files (part of this file has already been written to disk).";
    }

    // Old buffer size
    int L = m_bufferLen;
    uint8* convert = (uint8*)&L;

    // Zlib requires the output buffer to be this big
    unsigned long newSize = iCeil(m_bufferLen * 1.01) + 12;
    uint8* temp = (uint8*)System::malloc(newSize);
    int result = compress2(temp, &newSize, m_buffer, m_bufferLen, 9);

    debugAssert(result == Z_OK);
    (void)result;

    // Write the header
    if (m_swapBytes) {
        m_buffer[0] = convert[3];
        m_buffer[1] = convert[2];
        m_buffer[2] = convert[1];
        m_buffer[3] = convert[0];
    } else {
        m_buffer[0] = convert[0];
        m_buffer[1] = convert[1];
        m_buffer[2] = convert[2];
        m_buffer[3] = convert[3];
    }

    // Write the data
    if ((int64)newSize + 4 > (int64)m_maxBufferLen) {
        m_maxBufferLen = newSize + 4;
        m_buffer = (uint8*)System::realloc(m_buffer, m_maxBufferLen);
    }
    m_bufferLen = newSize + 4;
    System::memcpy(m_buffer + 4, temp, newSize);
    m_pos = m_bufferLen;

    System::free(temp);
}
Ejemplo n.º 16
0
std::string vformat(const char *fmt, va_list argPtr) {
    // We draw the line at a 1MB string.
    const int maxSize = 1000000;

    // If the string is less than 161 characters,
    // allocate it on the stack because this saves
    // the malloc/free time.
    const int bufSize = 161;
    char stackBuffer[bufSize];

    // MSVC6 doesn't support va_copy, however it also seems to compile
    // correctly if we just pass our argument list along.  Note that 
    // this whole code block is only compiled if we're on MSVC6 anyway
    int actualWritten = _vsnprintf(stackBuffer, bufSize, fmt, argPtr);

    // Not a big enough buffer, bufSize characters written
    if (actualWritten == -1) {

        int heapSize = 512;
        double powSize = 1.0;
        char* heapBuffer = (char*)System::malloc(heapSize);
        
        while ((_vsnprintf(heapBuffer, heapSize, fmt, argPtr) == -1) &&
            (heapSize  < maxSize)) {

            heapSize = iCeil(heapSize * ::pow((double)2.0, powSize++));
            heapBuffer = (char*)System::realloc(heapBuffer, heapSize);
        }

        heapBuffer[heapSize-1] = '\0';

        std::string heapString(heapBuffer);
        System::free(heapBuffer);

        return heapString;
    } else {

        return std::string(stackBuffer);
    }
}
Ejemplo n.º 17
0
void CDeflector::OA_Export()
{
	if (UVpolys.empty()) return;

	// Correct normal
	//  (semi-proportional to pixel density)
	FPU::m64r		();
	Fvector			tN;
	tN.set			(0,0,0);
	float density	= 0;
	float fcount	= 0;
	for (UVIt it = UVpolys.begin(); it!=UVpolys.end(); it++)
	{
		Face	*F = it->owner;
		Fvector	SN;
		SN.set	(F->N);
		SN.mul	(1+EPS*F->CalcArea());
		tN.add	(SN);

		density	+= F->Shader().lm_density;
		fcount	+= 1.f;
	}
	if (tN.magnitude()>EPS_S && _valid(tN))	normal.set(tN).normalize();
	else									clMsg("* ERROR: Internal precision error in CDeflector::OA_Export");
	density			/= fcount;
	
	// Orbitrary Oriented Ortho - Projection
	Fmatrix		mView;
    Fvector		at,from,up,right,y;
	at.set		(0,0,0);
	from.add	(at,normal);
	y.set		(0,1,0);
	if (_abs(normal.y)>.99f)		y.set(1,0,0);
	right.crossproduct(y,normal);	right.normalize_safe();
	up.crossproduct(normal,right);	up.normalize_safe();
	mView.build_camera(from,at,up);

	Fbox bb; bb.invalidate();
	for (UVIt it = UVpolys.begin(); it!=UVpolys.end(); it++)
	{
		UVtri	*T = &*it;
		Face	*F = T->owner;
		Fvector	P;	// projected

		for (int i=0; i<3; i++) {
			mView.transform_tiny	(P,F->v[i]->P);
			T->uv[i].set			(P.x,P.y);
			bb.modify				(F->v[i]->P);
		}
	}
	bb.getsphere(Sphere.P,Sphere.R);

	// UV rect
	Fvector2		min,max,size;
	GetRect			(min,max);
	size.sub		(max,min);

	// Surface
	u32 dwWidth		= iCeil(size.x*g_params.m_lm_pixels_per_meter*density+.5f); clamp(dwWidth, 1u,512u-2*BORDER);
	u32 dwHeight	= iCeil(size.y*g_params.m_lm_pixels_per_meter*density+.5f); clamp(dwHeight,1u,512u-2*BORDER);
	layer.create	(dwWidth,dwHeight);
}
Ejemplo n.º 18
0
void game_cl_ArtefactHunt::shedule_Update			(u32 dt)
{
	CStringTable st;
	string1024 msg;

	inherited::shedule_Update		(dt);

	if (g_dedicated_server)
		return;

	if (!m_game_ui)
		return;

	//out game information
	m_game_ui->SetBuyMsgCaption			(NULL);
	m_game_ui->SetPressBuyMsgCaption	(NULL);	

	switch (m_phase)
	{
	case GAME_PHASE_INPROGRESS:
		{
			if (local_player)
			{
				if (local_player->testFlag(GAME_PLAYER_FLAG_ONBASE) &&
					!local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
				{
					m_bBuyEnabled = TRUE;
				}
				else
				{
					m_bBuyEnabled = FALSE;
				};
			};			

			if (local_player && Level().CurrentControlEntity())
			{
				if (smart_cast<CActor*>(Level().CurrentControlEntity()))
				{
					if(m_game_ui) m_game_ui->SetBuyMsgCaption("");
					if (m_bBuyEnabled)
					{
						if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && 
							!(pCurSkinMenu && pCurSkinMenu->IsShown()))
						{					
							xr_sprintf(msg, *st.translate("mp_press_to_buy"), "B");
							if(m_game_ui) m_game_ui->SetBuyMsgCaption(msg);
						};
					}					
					
					if (m_game_ui)
					{
						if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
							m_game_ui->SetPressJumpMsgCaption("mp_press_fire2spectator");
						else
							m_game_ui->SetPressJumpMsgCaption(NULL);
					};
				}
				else
				{					
					if(m_game_ui) m_game_ui->SetBuyMsgCaption(NULL);
					if (m_bTeamSelected && m_bSkinSelected)
					{
						if (iReinforcementTime != 0)
						{
							if (!m_game_ui->m_pBuySpawnMsgBox->IsShown() &&
								(local_player->money_for_round+m_iSpawn_Cost)>=0)
							{
								if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2pay_spaw");
							}
							else
							{
								if (m_game_ui) m_game_ui->SetPressJumpMsgCaption(NULL);
							}
						}
						else
						{
							if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2spawn");
						};
					}
					else
					{
						if (!m_bTeamSelected)
							if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_team");
							else
								if (!m_bSkinSelected)
									if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_skin");
					}
				};				
			}

			if (local_player)
			{
				game_TeamState team0 = teams[0];
				game_TeamState team1 = teams[1];

				if (dReinforcementTime > 0 && Level().CurrentViewEntity() && m_cl_dwWarmUp_Time == 0)
				{
					u32 CurTime = Level().timeServer();
					u32 dTime;
					if (s32(CurTime) > dReinforcementTime) dTime = 0;
					else dTime = iCeil(float(dReinforcementTime - CurTime) / 1000);
							
					string128 _buff;
					m_game_ui->m_pReinforcementInidcator->SetText(itoa(dTime,_buff,10));
				}else
					m_game_ui->m_pReinforcementInidcator->SetText("0");

				s16 lt = local_player->team;
				if (lt>=0)
				{
//					if(m_game_ui) m_game_ui->SetScoreCaption	(teams[0].score, teams[1].score);
				};				
			};
			SetScore();
		}break;
	case GAME_PHASE_TEAM1_ELIMINATED:
		{
			m_game_ui->SetRoundResultCaption("Team Green ELIMINATED!");
			SetScore();
		}break;
	case GAME_PHASE_TEAM2_ELIMINATED:
		{
			m_game_ui->SetRoundResultCaption("Team Blue ELIMINATED!");
			SetScore();
		}break;
	default:
		{
			
		}break;
	};

	if (m_game_ui->m_pBuySpawnMsgBox->IsShown())
	{
		if (m_phase != GAME_PHASE_INPROGRESS || (!local_player || !local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)))
		{
			m_game_ui->m_pBuySpawnMsgBox->HideDialog();
		};
	};
	//-------------------------------------------

}
Ejemplo n.º 19
0
void CPHCallOnStepCondition::set_time_interval(float time)
{
		set_steps_interval(iCeil(time/fixed_step));
}
Ejemplo n.º 20
0
void CInventoryItem::CalculateInterpolationParams()
{
	net_updateData* p = NetSync();
	p->IStartPos.set(object().Position());
	p->IStartRot.set(object().XFORM());

	Fvector P0, P1, P2, P3;

	CPHSynchronize* pSyncObj = NULL;
	pSyncObj = object().PHGetSyncItem(0);
	
	Fmatrix xformX0, xformX1;	

	if (m_flags.test(FInInterpolation))
	{
		u32 CurTime = Level().timeServer();
		float factor	= float(CurTime - p->m_dwIStartTime)/(p->m_dwIEndTime - p->m_dwIStartTime);
		if (factor > 1.0f) factor = 1.0f;

		float c = factor;
		for (u32 k=0; k<3; k++)
		{
			P0[k] = c*(c*(c*p->SCoeff[k][0]+p->SCoeff[k][1])+p->SCoeff[k][2])+p->SCoeff[k][3];
			P1[k] = (c*c*p->SCoeff[k][0]*3+c*p->SCoeff[k][1]*2+p->SCoeff[k][2])/3; // сокрость из формулы в 3 раза превышает скорость при расчете коэффициентов !!!!
		};
		P0.set(p->IStartPos);
		P1.add(p->IStartPos);
	}	
	else
	{
		P0 = p->IStartPos;

		if (p->LastState.linear_vel.x == 0 && 
			p->LastState.linear_vel.y == 0 && 
			p->LastState.linear_vel.z == 0)
		{
			pSyncObj->cv2obj_Xfrom(p->RecalculatedState.previous_quaternion, p->RecalculatedState.previous_position, xformX0);
			pSyncObj->cv2obj_Xfrom(p->RecalculatedState.quaternion, p->RecalculatedState.position, xformX1);
		}
		else
		{
			pSyncObj->cv2obj_Xfrom(p->LastState.previous_quaternion, p->LastState.previous_position, xformX0);
			pSyncObj->cv2obj_Xfrom(p->LastState.quaternion, p->LastState.position, xformX1);
		};

		P1.sub(xformX1.c, xformX0.c);
		P1.add(p->IStartPos);
	}

	P2.sub(p->PredictedState.position, p->PredictedState.linear_vel);
	pSyncObj->cv2obj_Xfrom(p->PredictedState.quaternion, P2, xformX0);
	P2.set(xformX0.c);

	pSyncObj->cv2obj_Xfrom(p->PredictedState.quaternion, p->PredictedState.position, xformX1);
	P3.set(xformX1.c);
	/////////////////////////////////////////////////////////////////////////////
	Fvector TotalPath;
	TotalPath.sub(P3, P0);
	float TotalLen = TotalPath.magnitude();
	
	SPHNetState	State0 = (p->NET_IItem.back()).State;
	SPHNetState	State1 = p->PredictedState;

	float lV0 = State0.linear_vel.magnitude();
	float lV1 = State1.linear_vel.magnitude();

	u32		ConstTime = u32((fixed_step - ph_world->m_frame_time)*1000)+ Level().GetInterpolationSteps()*u32(fixed_step*1000);
	
	p->m_dwIStartTime = p->m_dwILastUpdateTime;

	if (( lV0 + lV1) > 0.000001 && g_cl_lvInterp == 0)
	{
		u32		CulcTime = iCeil(TotalLen*2000/( lV0 + lV1));
		p->m_dwIEndTime = p->m_dwIStartTime + min(CulcTime, ConstTime);
	}
	else
		p->m_dwIEndTime = p->m_dwIStartTime + ConstTime;
	/////////////////////////////////////////////////////////////////////////////
	Fvector V0, V1;
	V0.sub(P1, P0);
	V1.sub(P3, P2);
	lV0 = V0.magnitude();
	lV1 = V1.magnitude();

	if (TotalLen != 0)
	{
		if (V0.x != 0 || V0.y != 0 || V0.z != 0)
		{
			if (lV0 > TotalLen/3)
			{
				V0.normalize();
				V0.mul(TotalLen/3);
				P1.add(V0, P0);
			}
		}
		
		if (V1.x != 0 || V1.y != 0 || V1.z != 0)
		{
			if (lV1 > TotalLen/3)
			{
				V1.normalize();
				V1.mul(TotalLen/3);
				P2.sub(P3, V1);
			};
		}
	};
	/////////////////////////////////////////////////////////////////////////////
	for( u32 i =0; i<3; i++)
	{
		p->SCoeff[i][0] = P3[i]	- 3*P2[i] + 3*P1[i] - P0[i];
		p->SCoeff[i][1] = 3*P2[i]	- 6*P1[i] + 3*P0[i];
		p->SCoeff[i][2] = 3*P1[i]	- 3*P0[i];
		p->SCoeff[i][3] = P0[i];
	};
	/////////////////////////////////////////////////////////////////////////////
	m_flags.set	(FInInterpolation, TRUE);

	if (object().m_pPhysicsShell) object().m_pPhysicsShell->NetInterpolationModeON();

};
Ejemplo n.º 21
0
// Rasterize a scan line between given X point values, corresponding Z values and current color
void i_scan		(int curY, float leftX, float lhx, float rightX, float rhx, float startZ, float endZ)
{
	// calculate span(s)
	float	start_c	= leftX+lhx;
	float	end_c	= rightX+rhx;
	
	float	startR	= leftX-lhx;
	float	endR	= rightX-rhx;
	
	float	startT	=startR,	endT	=end_c;
	float	startX	=start_c,	endX	=endR;
	if (start_c<startR)		{startT	= start_c;	startX	= startR;	}
	if (end_c<endR)			{endT	= endR;		endX	= end_c;	}
	
	// guard-banding and clipping
	int minT		= iFloor(startT)-1, maxT = iCeil(endT)+1;
	Vclamp			(minT,1,occ_dim-1);
	Vclamp			(maxT,1,occ_dim-1);
	if (minT >= maxT)		return;
	
	int minX		= iCeil(startX), maxX = iFloor(endX);
	Vclamp			(minX,0,occ_dim);
	Vclamp			(maxX,0,occ_dim);
	int limLeft,limRight;
	if (minX >  maxX)	{ limLeft=maxX; limRight=minX;	}
	else				{ limLeft=minX; limRight=maxX;	}
	
	// interpolate
	float lenR		= endR - startR;
	float Zlen		= endZ - startZ;
	float Z			= startZ + (minT - startR)/lenR * Zlen;		// interpolate Z to the start
	float Zend		= startZ + (maxT - startR)/lenR * Zlen;		// interpolate Z to the end
	float dZ		= (Zend-Z)/(maxT-minT);						// increment in Z / pixel wrt dX

	// Move to far my dz/5 to place the pixel at the center of face that it covers. 
	// This will make sure that objects will not be clipped for just standing next to the home from outside.
	Z				+= 0.5f*_abs(dZ);

	// gain access to buffers
	occTri** pFrame	= Raster.get_frame();
	float*	pDepth	= Raster.get_depth();
	
	// left connector
	int	i_base		= curY*occ_dim;
	int i			= i_base+minT;
	int limit		= i_base+limLeft;
	for (; i<limit; i++, Z+=dZ)
	{
		if (shared(currentTri,pFrame[i-1])) 
		{
			//float ZR = (Z+2*pDepth[i-1])*one_div_3;
			if (Z<pDepth[i])	{ pFrame[i]	= currentTri; pDepth[i]	= __max(Z,pDepth[i-1]); dwPixels++; }
		}
	}

	// compute the scanline 
	limit				= i_base+maxX;
	for (; i<limit; i++, Z+=dZ) 
	{
		if (Z<pDepth[i])		{ pFrame[i]	= currentTri; pDepth[i] = Z;  dwPixels++; }
	}
	
	// right connector
	i				= i_base+maxT-1;
	limit			= i_base+limRight;
	Z				= Zend-dZ;
	for (; i>=limit; i--, Z-=dZ)
	{
		if (shared(currentTri,pFrame[i+1])) 
		{
			//float ZR = (Z+2*pDepth[i+1])*one_div_3;
			if (Z<pDepth[i])	{ pFrame[i]	= currentTri; pDepth[i]	= __max(Z,pDepth[i+1]); dwPixels++; }
		}
	}
}
Ejemplo n.º 22
0
IC void i_section	(int Sect, BOOL bMiddle)
{
	// Find the start/end Y pixel coord, set the starting pts for scan line ends
	int		startY, endY;
	float	*startp1, *startp2;
	float	E1[3], E2[3];

	if (Sect == BOTTOM) { 
		startY	= iCeil(currentA[1]); endY = iFloor(currentB[1])-1; 
		startp1 = startp2 = currentA;
		if (bMiddle)	endY ++;
		
		// check 'endY' for out-of-triangle 
		int test = iFloor(currentC[1]);
		if (endY   >=test) endY --;

		// Find the edge differences
		E1[0] = currentB[0]-currentA[0]; E2[0] = currentC[0]-currentA[0];
		E1[1] = currentB[1]-currentA[1]; E2[1] = currentC[1]-currentA[1];
		E1[2] = currentB[2]-currentA[2]; E2[2] = currentC[2]-currentA[2];
	}
	else { 
		startY  = iCeil(currentB[1]); endY = iFloor(currentC[1]); 
		startp1 = currentA; startp2 = currentB;
		if (bMiddle)	startY --;
		
		// check 'startY' for out-of-triangle 
		int test = iCeil(currentA[1]);
		if (startY < test) startY ++;

		// Find the edge differences
		E1[0] = currentC[0]-currentA[0]; E2[0] = currentC[0]-currentB[0];
		E1[1] = currentC[1]-currentA[1]; E2[1] = currentC[1]-currentB[1];
		E1[2] = currentC[2]-currentA[2]; E2[2] = currentC[2]-currentB[2];
	}
	Vclamp(startY,0,occ_dim);
	Vclamp(endY,  0,occ_dim);
	if (startY >= endY) return;
	
	// Compute the inverse slopes of the lines, ie rate of change of X by Y
	float mE1	= E1[0]/E1[1];
	float mE2	= E2[0]/E2[1];
	
	// Initial Y offset for left and right (due to pixel rounding)
	float	e1_init_dY = float(startY) - startp1[1], e2_init_dY = float(startY) - startp2[1];
	float	t,leftX, leftZ, rightX, rightZ, left_dX, right_dX, left_dZ, right_dZ;
	
	// find initial values, step values
	if ( ((mE1<mE2)&&(Sect==BOTTOM)) || ((mE1>mE2)&&(Sect==TOP)) ) 
	{ 
		// E1 is on the Left
		// Initial Starting values for left (from E1)
		t		= e1_init_dY/E1[1]; // Initial fraction of offset
		leftX	= startp1[0] + E1[0]*t; left_dX = mE1;
		leftZ	= startp1[2] + E1[2]*t; left_dZ = E1[2]/E1[1];

		// Initial Ending values for right	(from E2)
		t		= e2_init_dY/E2[1]; // Initial fraction of offset
		rightX	= startp2[0] + E2[0]*t; right_dX = mE2;
		rightZ	= startp2[2] + E2[2]*t; right_dZ = E2[2]/E2[1];
	}
	else { 
		// E2 is on left
		// Initial Starting values for left (from E2)
		t		= e2_init_dY/E2[1]; // Initial fraction of offset
		leftX	= startp2[0] + E2[0]*t; left_dX = mE2;
		leftZ	= startp2[2] + E2[2]*t; left_dZ = E2[2]/E2[1];

		// Initial Ending values for right	(from E1)
		t		= e1_init_dY/E1[1]; // Initial fraction of offset
		rightX	= startp1[0] + E1[0]*t; right_dX = mE1;
		rightZ	= startp1[2] + E1[2]*t; right_dZ = E1[2]/E1[1];
	}

	// Now scan all lines in this section
	float lhx = left_dX/2;	leftX	+= lhx;	// half pixel
	float rhx = right_dX/2;	rightX	+= rhx;	// half pixel
	for (; startY<=endY; startY++) 
	{
		i_scan	(startY, leftX, lhx, rightX, rhx, leftZ, rightZ);
		leftX	+= left_dX; rightX += right_dX;
		leftZ	+= left_dZ; rightZ += right_dZ;
	}
}
Ejemplo n.º 23
0
void CUIFrameWindow::DrawElements()
{
	UIRender->SetShader			(*m_shader);

	Fvector2					ts;
	UIRender->GetActiveTextureResolution(ts);

	Frect						rect;
	GetAbsoluteRect				(rect);
	UI().ClientToScreenScaled	(rect.lt);
	UI().ClientToScreenScaled	(rect.rb);
	
	Fvector2 back_len			= {0.0f, 0.0f};
	u32 rect_count				= 4; //lt+rt+lb+rb
	back_len.x					= rect.width()-m_tex_rect[fmLT].width()-m_tex_rect[fmRT].width();
	back_len.y					= rect.height()-m_tex_rect[fmLT].height()-m_tex_rect[fmRB].height();
	R_ASSERT					(back_len.x+EPS_L>=0.0f && back_len.y+EPS_L>=0.0f);
	
	u32 cnt =0;
	if(back_len.x>0.0f)//top+bottom
		cnt						= 2* iCeil(back_len.x/m_tex_rect[fmT].width());
	rect_count					+= cnt;

	if(back_len.y>0.0f)//left+right
		cnt						= 2* iCeil(back_len.y/m_tex_rect[fmL].height());
	rect_count					+= cnt;
	
	if(back_len.x>0.0f && back_len.y>0.0f) //back
		cnt						= iCeil(back_len.x/m_tex_rect[fmBK].width()) * iCeil(back_len.y/m_tex_rect[fmBK].height()) ;

	rect_count					+= cnt;

	rect_count					*= 6;
	
	UIRender->StartPrimitive	(rect_count, IUIRender::ptTriList, UI().m_currentPointType);

	Fvector2 LTt, RBt;
	Fvector2 LTp, RBp;

	Frect tmp					= rect;
	get_points					(tmp, fmLT, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.lt.x;
	tmp.lt.y					= rect.rb.y - m_tex_rect[fmLB].height();
	get_points					(tmp, fmLB, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.rb.x - m_tex_rect[fmRT].width();
	tmp.lt.y					= rect.lt.y;;
	get_points					(tmp, fmRT, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	tmp.lt.x					= rect.rb.x - m_tex_rect[fmRB].width();
	tmp.lt.y					= rect.rb.y - m_tex_rect[fmRB].height();
	get_points					(tmp, fmRB, LTp, RBp, LTt, RBt);
	draw_rect					(LTp, RBp, LTt, RBt, m_texture_color, ts);

	if(back_len.x>0.0f)
	{
		tmp.lt					= rect.lt;
		tmp.lt.x				+= m_tex_rect[fmLT].width();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRT].width();
		tmp.rb.y				= rect.lt.y+m_tex_rect[fmT].height();
		draw_tile_line			(tmp, fmT, true, ts);

		tmp.lt.x				= rect.lt.x+m_tex_rect[fmLT].width();
		tmp.lt.y				= rect.rb.y-m_tex_rect[fmB].height();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRT].width();
		tmp.rb.y				= rect.rb.y;
		draw_tile_line			(tmp, fmB, true, ts);
	}

	if(back_len.y>0.0f)
	{
		tmp.lt					= rect.lt;
		tmp.lt.y				+= m_tex_rect[fmLT].height();
		tmp.rb.x				= rect.lt.x+m_tex_rect[fmL].width();
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmLB].height();
		draw_tile_line			(tmp, fmL, false, ts);

		tmp.lt.x				= rect.rb.x-m_tex_rect[fmR].width();
		tmp.lt.y				= rect.lt.y+m_tex_rect[fmRT].height();;
		tmp.rb.x				= rect.rb.x;
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmRB].height();
		draw_tile_line			(tmp, fmR, false, ts);
	}

	if(back_len.x>0.0f && back_len.y>0.0f)
	{
		tmp.lt.x				= rect.lt.x+m_tex_rect[fmLT].width();
		tmp.lt.y				= rect.lt.y+m_tex_rect[fmLT].height();
		tmp.rb.x				= rect.rb.x-m_tex_rect[fmRB].width();
		tmp.rb.y				= rect.rb.y-m_tex_rect[fmRB].height();
		draw_tile_rect			(tmp, fmBK, ts);
	}

	UIRender->FlushPrimitive	();
}
Ejemplo n.º 24
0
Vector3int16 Vector3int16::ceil(const Vector3& v) {
    return Vector3int16(iCeil(v.x), iCeil(v.y), iCeil(v.z));
}
Ejemplo n.º 25
0
void CUIHudStatesWnd::UpdateHealth( CActor* actor )
{
//	if ( Device.dwTimeGlobal - m_timer_1sec > 1000 ) // 1 sec
//	{
//		m_timer_1sec = Device.dwTimeGlobal;
//	}
	
	float cur_health = actor->GetfHealth();
	m_ui_health_bar->SetProgressPos(iCeil(cur_health * 100.0f * 35.f) / 35.f);
	if ( _abs(cur_health - m_last_health) > m_health_blink )
	{
		m_last_health = cur_health;
		m_ui_health_bar->m_UIProgressItem.ResetColorAnimation();
	}
	
	float cur_stamina = actor->conditions().GetPower();
	m_ui_stamina_bar->SetProgressPos(iCeil(cur_stamina * 100.0f * 35.f) / 35.f);
	if ( !actor->conditions().IsCantSprint() )
	{
		m_ui_stamina_bar->m_UIProgressItem.ResetColorAnimation();
	}

/*
	CCustomOutfit* outfit = actor->GetOutfit();
	if ( outfit )
	{
		m_static_armor->Show( true );
		m_ui_armor_bar->Show( true );
		m_ui_armor_bar->SetProgressPos( outfit->GetCondition() * 100.0f );
	}
	else
	{
		m_static_armor->Show( false );
		m_ui_armor_bar->Show( false );
	}
*/	
	/*
	float bleeding_speed = actor->conditions().BleedingSpeed();
	if(bleeding_speed > 0.01f)
		m_bleeding_lev1->Show(true);
	else
		m_bleeding_lev1->Show(false);

	if(bleeding_speed > 0.35f)
		m_bleeding_lev2->Show(true);
	else
		m_bleeding_lev2->Show(false);
	
	if(bleeding_speed > 0.7f)
		m_bleeding_lev3->Show(true);
	else
		m_bleeding_lev3->Show(false);
	
	
	if(m_radia_self > 0.01f)
		m_radiation_lev1->Show(true);
	else
		m_radiation_lev1->Show(false);

	if(m_radia_self > 0.35f)
		m_radiation_lev2->Show(true);
	else
		m_radiation_lev2->Show(false);
	
	if(m_radia_self > 0.7f)
		m_radiation_lev3->Show(true);
	else
		m_radiation_lev3->Show(false);
		*/
}
void CLight_Compute_XFORM_and_VIS::compute_xf_spot	(light* L)
{
	// Build EYE-space xform
	Fvector						L_dir,L_up,L_right,L_pos;
	L_dir.set					(L->direction);			L_dir.normalize		();

	if (L->right.square_magnitude()>EPS)				{
		// use specified 'up' and 'right', just enshure ortho-normalization
		L_right.set					(L->right);				L_right.normalize	();
		L_up.crossproduct			(L_dir,L_right);		L_up.normalize		();
		L_right.crossproduct		(L_up,L_dir);			L_right.normalize	();
	} else {
		// auto find 'up' and 'right' vectors
		L_up.set					(0,1,0);				if (_abs(L_up.dotproduct(L_dir))>.99f)	L_up.set(0,0,1);
		L_right.crossproduct		(L_up,L_dir);			L_right.normalize	();
		L_up.crossproduct			(L_dir,L_right);		L_up.normalize		();
	}
	L_pos.set						(L->position);
	
	// 
	int _cached_size			= L->X.S.size;
	L->X.S.posX	= L->X.S.posY	= 0;
	L->X.S.size					= SMAP_adapt_max;
	L->X.S.transluent			= FALSE;

	// Compute approximate screen area (treating it as an point light) - R*R/dist_sq
	// Note: we clamp screen space area to ONE, although it is not correct at all
	float	dist				= Device.vCameraPosition.distance_to(L->spatial.sphere.P)-L->spatial.sphere.R;
			if (dist<0)	dist	= 0;
	float	ssa					= clampr	(L->range*L->range / (1.f+dist*dist),0.f,1.f);

	// compute intensity
	float	intensity0			= (L->color.r + L->color.g + L->color.b)/3.f;
	float	intensity1			= (L->color.r * 0.2125f + L->color.g * 0.7154f + L->color.b * 0.0721f);
	float	intensity			= (intensity0+intensity1)/2.f;		// intensity1 tends to underestimate...

	// compute how much duelling frusta occurs	[-1..1]-> 1 + [-0.5 .. +0.5]
	float	duel_dot			= 1.f -	0.5f*Device.vCameraDirection.dotproduct(L_dir);

	// compute how large the light is - give more texels to larger lights, assume 8m as being optimal radius
	float	sizefactor			= L->range/8.f;				// 4m = .5, 8m=1.f, 16m=2.f, 32m=4.f

	// compute how wide the light frustum is - assume 90deg as being optimal
	float	widefactor			= L->cone/deg2rad(90.f);	// 

	// factors
	float	factor0				= powf	(ssa,		1.f/2.f);		// ssa is quadratic
	float	factor1				= powf	(intensity, 1.f/16.f);		// less perceptually important?
	float	factor2				= powf	(duel_dot,	1.f/4.f);		// difficult to fast-change this -> visible
	float	factor3				= powf	(sizefactor,1.f/4.f);		// this shouldn't make much difference
	float	factor4				= powf	(widefactor,1.f/2.f);		// make it linear ???
	float	factor				= ps_r2_ls_squality * factor0 * factor1 * factor2 * factor3 * factor4;
	
	// final size calc
	u32 _size					= iFloor( factor * SMAP_adapt_optimal );
	if (_size<SMAP_adapt_min)	_size	= SMAP_adapt_min;
	if (_size>SMAP_adapt_max)	_size	= SMAP_adapt_max;
	int _epsilon				= iCeil	(float(_size)*0.01f);
	int _diff					= _abs	(int(_size)-int(_cached_size));
	L->X.S.size					= (_diff>=_epsilon)?_size:_cached_size;

	// make N pixel border
	L->X.S.view.build_camera_dir	(L_pos,L_dir,L_up);
	//float	n			= 2.f						;
	//float	x			= float(L->X.S.size)		;
	//float	alpha		= L->cone/2					;
	//float	tan_beta	= (x+2*n)*tanf(alpha) / x	;
	//float	g_alpha		= 2*rad2deg		(alpha);
	//float	g_beta		= 2*rad2deg		(atanf(tan_beta));
	//Msg				("x(%f) : a(%f), b(%f)",x,g_alpha,g_beta);
	/************************************************** added by Ray Twitty (aka Shadows) START **************************************************/
	// только для поинта меняем на 11.5
	float				tan_shift;
	if (L->flags.type == IRender_Light::POINT)
		tan_shift		= deg2rad(11.5f);
	else
		tan_shift		= deg2rad(3.5f);
	/*************************************************** added by Ray Twitty (aka Shadows) END ***************************************************/
	L->X.S.project.build_projection		(L->cone + tan_shift, 1.f,/*SMAP_near_plane*/L->virtual_size,L->range+EPS_S);
	L->X.S.combine.mul					(L->X.S.project,L->X.S.view);
}