本文整理汇总了C++中s32函数的典型用法代码示例。如果您正苦于以下问题:C++ s32函数的具体用法?C++ s32怎么用?C++ s32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s32
// fills attributes with statistics information
void CImpostorSceneNode::getStats( io::IAttributes* statistics)
{
statistics->setAttribute("Nodes", s32(Impostors.size()));
//statistics->setAttribute("Lights", 0 ); // todo
statistics->setAttribute("Buffers", s32(Buffers.size()));
s32 TotalSlots=0, UsedSlots=0;
for (u32 i=0; i<Buffers.size(); ++i)
{
TotalSlots+= Buffers[i].Slots.size();
UsedSlots += Buffers[i].Slots.size() - Buffers[i].FreeSlots;
}
statistics->setAttribute("TotalSlots", TotalSlots);
statistics->setAttribute("UsedSlots", UsedSlots);
statistics->setAttribute("SlotUsage%", f32(UsedSlots)/ f32(TotalSlots) * 100.0f);
statistics->setAttribute("TotalTextureMB", f32(Buffers.size()*TextureWidth*TextureWidth*4)/1048576.0f );
statistics->setAttribute("QueueLength", s32(RenderQueue.size()));
//statistics->setAttribute("AverageQueueLength", 0); // todo
// todo
statistics->setAttribute("RenderCount", RenderCount);
statistics->setAttribute("CacheHit%", (f32(CacheHits) / f32(CacheHits + CacheMisses)) * 100.0f );
statistics->setAttribute("CacheHits", CacheHits);
statistics->setAttribute("CacheMisses", CacheMisses);
//statistics->setAttribute("LastRegisterTime", 0);
//statistics->setAttribute("TotalRegisterTime", 0);
//statistics->setAttribute("AvgRegisterTime", 0);
//statistics->setAttribute("LastRenderTime", 0);
//statistics->setAttribute("TotalRenderTime", 0);
//statistics->setAttribute("AvgRenderTime", 0);
}
示例2: R_CHK
void CSoundRender_TargetD::fill_parameters()
{
inherited::fill_parameters();
// 1. Set 3D params (including mode)
{
Fvector& p_pos = pEmitter->p_source.position;
R_CHK(pControl->SetMode (pEmitter->b2D ? DS3DMODE_HEADRELATIVE : DS3DMODE_NORMAL,DS3D_DEFERRED));
R_CHK(pControl->SetMinDistance (pEmitter->p_source.min_distance, DS3D_DEFERRED));
R_CHK(pControl->SetMaxDistance (pEmitter->p_source.max_distance, DS3D_DEFERRED));
R_CHK(pControl->SetPosition (p_pos.x,p_pos.y,p_pos.z, DS3D_DEFERRED));
}
// 2. Set 2D params (volume, freq) + position(rewind)
{
float _volume = pEmitter->smooth_volume; clamp (_volume,EPS_S,1.f);
s32 hw_volume = iFloor (7000.f*logf(_volume)/5.f); clamp (hw_volume,DSBVOLUME_MIN,DSBVOLUME_MAX);
if (_abs(hw_volume-cache_hw_volume)>50){
cache_hw_volume = hw_volume;
R_CHK(pBuffer->SetVolume(hw_volume));
}
float _freq = pEmitter->p_source.freq;
s32 hw_freq = iFloor (_freq * float(wfx.nSamplesPerSec) + EPS);
if (_abs(hw_freq-cache_hw_freq)>50) {
cache_hw_freq = hw_freq;
s32 hw_freq_set = hw_freq;
clamp (hw_freq_set,s32(SoundRenderD->dsCaps.dwMinSecondarySampleRate),s32(SoundRenderD->dsCaps.dwMaxSecondarySampleRate));
R_CHK (pBuffer->SetFrequency ( hw_freq_set ));
}
}
}
示例3: Ceiling
inline s32 Ceiling(const T& val)
{
if(val == s32(val))
return s32(val);
else if(val < T(0))
return s32(val);
else
return (s32(val) + 1);
}
示例4: Floor
inline s32 Floor(const T& val)
{
if(val == s32(val))
return s32(val);
else if(val < T(0))
return (s32(val) - 1);
else
return s32(val);
}
示例5: s32
bool Jungle::treeExistAt(core::vector3df position)
{
//
position /= this->getScale();
s32 idx = s32(position.X / CHUNK_RENDER_DIMENSION);
s32 idy = s32(position.Z / CHUNK_RENDER_DIMENSION);
if(idx < 0)return false;
if(idy < 0)return false;
if(idx >= WORLD_SIZE)return false;
if(idy >= WORLD_SIZE)return false;
return chunks[idx][idy].treeExistAt(position);
}
示例6: setNewActivePhysicsRect
void setNewActivePhysicsRect(daMegaGoomba_c *actor, Vec *scale) {
float amtX = scale->x * 0.5f;
float amtY = scale->y * 0.5f;
actor->belowSensor.flags = SENSOR_LINE;
actor->belowSensor.lineA = s32((amtX * -28.0f) * 4096.0f);
actor->belowSensor.lineB = s32((amtX * 28.0f) * 4096.0f);
actor->belowSensor.distanceFromCenter = 0;
actor->adjacentSensor.flags = SENSOR_LINE;
actor->adjacentSensor.lineA = s32((amtY * 4.0f) * 4096.0f);
actor->adjacentSensor.lineB = s32((amtY * 32.0f) * 4096.0f);
actor->adjacentSensor.distanceFromCenter = s32((amtX * 46.0f) * 4096.0f);
u8 cat1 = 3, cat2 = 0;
u32 bitfield1 = 0x6f, bitfield2 = 0xffbafffe;
ActivePhysics::Info info = {
0.0f, amtY*57.0f, amtX*20.0f, amtY*31.0f,
cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
actor->aPhysics.initWithStruct(actor, &info);
// Original trapezium was -12,12 to -48,48
ActivePhysics::Info left = {
amtX*-32.0f, amtY*55.0f, amtX*12.0f, amtY*30.0f,
cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
actor->leftTrapAPhysics.initWithStruct(actor, &left);
actor->leftTrapAPhysics.trpValue0 = amtX * 12.0f;
actor->leftTrapAPhysics.trpValue1 = amtX * 12.0f;
actor->leftTrapAPhysics.trpValue2 = amtX * -12.0f;
actor->leftTrapAPhysics.trpValue3 = amtX * 12.0f;
actor->leftTrapAPhysics.collisionCheckType = 3;
ActivePhysics::Info right = {
amtX*32.0f, amtY*55.0f, amtX*12.0f, amtY*30.0f,
cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
actor->rightTrapAPhysics.initWithStruct(actor, &right);
actor->rightTrapAPhysics.trpValue0 = amtX * -12.0f;
actor->rightTrapAPhysics.trpValue1 = amtX * -12.0f;
actor->rightTrapAPhysics.trpValue2 = amtX * -12.0f;
actor->rightTrapAPhysics.trpValue3 = amtX * 12.0f;
actor->rightTrapAPhysics.collisionCheckType = 3;
ActivePhysics::Info stalk = {
0.0f, amtY*12.0f, amtX*28.0f, amtY*12.0f,
cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
actor->stalkAPhysics.initWithStruct(actor, &stalk);
}
示例7: f32
s32 CGUIScrollBar::getPosFromMousePos(s32 x, s32 y) const
{
if (Horizontal)
{
const f32 w = RelativeRect.getWidth() - f32(RelativeRect.getHeight())*3.0f;
const f32 p = x - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight()*1.5f;
return s32( p/w * f32(Max) );
}
else
{
const f32 h = RelativeRect.getHeight() - f32(RelativeRect.getWidth())*3.0f;
const f32 p = y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth()*1.5f;
return s32( p/h * f32(Max) );
}
}
示例8: arma_extra_debug_sigprint
inline
void
op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagvec>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const s32 id = (X.aux_u32_b > 0) ? -s32(X.aux_u32_a) : s32(X.aux_u32_a);
const unwrap_check<T1> tmp(X.m, out);
const Mat<eT>& A = tmp.M;
out = A.diag(id);
}
示例9: DAEDALUS_PROFILE
//*************************************************************************************
//
//*************************************************************************************
void CTraceRecorder::Analyse( SRegisterUsageInfo & register_usage )
{
DAEDALUS_PROFILE( "CTraceRecorder::Analyse" );
std::pair< s32, s32 > reg_spans[ NUM_N64_REGS ];
std::pair< s32, s32 > invalid_span( std::pair< s32, s32 >( mTraceBuffer.size(), -1 ) );
std::fill( reg_spans, reg_spans + NUM_N64_REGS, invalid_span ); // Set the interval to an invalid range
for( u32 i = 0; i < mTraceBuffer.size(); ++i )
{
const STraceEntry & ti( mTraceBuffer[ i ] );
const StaticAnalysis::RegisterUsage& usage = ti.Usage;
register_usage.RegistersRead |= usage.RegReads;
register_usage.RegistersWritten |= usage.RegWrites;
register_usage.RegistersAsBases |= usage.RegBase;
u32 all_uses( usage.RegReads | usage.RegWrites | usage.RegBase );
// Update the live span
for( s32 reg = 1; reg < NUM_N64_REGS; ++reg )
{
if( all_uses & (1<<reg) )
{
if( s32( i ) < reg_spans[ reg ].first ) reg_spans[ reg ].first = i;
if( s32( i ) > reg_spans[ reg ].second ) reg_spans[ reg ].second = i;
}
}
}
register_usage.SpanList.clear();
register_usage.SpanList.reserve( NUM_N64_REGS );
// Iterate through registers, inserting all that are used into span list
for( u32 i = 0; i < NUM_N64_REGS; ++i )
{
s32 start( reg_spans[ i ].first );
s32 end( reg_spans[ i ].second );
if( start <= end )
{
SRegisterSpan span( EN64Reg( i ), start, end );
register_usage.SpanList.push_back( span );
}
}
}
示例10: readHeader
// returns true on success
bool CImageLoaderRGB::readHeader(io::IReadFile* file, rgbStruct& rgb) const
{
if ( file->read(&rgb.Header, sizeof(rgb.Header)) < s32(sizeof(rgb.Header)) )
return false;
// test for INTEL or BIG ENDIAN processor
// if INTEL, then swap the byte order on 16 bit INT's to make them BIG ENDIAN
// because that is the native format for the .rgb file
#ifndef __BIG_ENDIAN__
rgb.Header.Magic = os::Byteswap::byteswap(rgb.Header.Magic);
rgb.Header.Storage = os::Byteswap::byteswap(rgb.Header.Storage);
rgb.Header.Dimension = os::Byteswap::byteswap(rgb.Header.Dimension);
rgb.Header.Xsize = os::Byteswap::byteswap(rgb.Header.Xsize);
rgb.Header.Ysize = os::Byteswap::byteswap(rgb.Header.Ysize);
rgb.Header.Zsize = os::Byteswap::byteswap(rgb.Header.Zsize);
rgb.Header.Pixmin = os::Byteswap::byteswap(rgb.Header.Pixmin);
rgb.Header.Pixmax = os::Byteswap::byteswap(rgb.Header.Pixmax);
rgb.Header.Colormap = os::Byteswap::byteswap(rgb.Header.Colormap);
#endif
// calculate the size of the buffer needed: XSIZE * YSIZE * ZSIZE * BPC
rgb.ImageSize = (rgb.Header.Xsize)*(rgb.Header.Ysize)*(rgb.Header.Zsize)*(rgb.Header.BPC);
return true;
}
示例11: inventory
void CActor::OnPrevWeaponSlot()
{
u32 ActiveSlot = inventory().GetActiveSlot();
if (ActiveSlot == NO_ACTIVE_SLOT)
ActiveSlot = inventory().GetPrevActiveSlot();
if (ActiveSlot == NO_ACTIVE_SLOT)
ActiveSlot = KNIFE_SLOT;
u32 NumSlotsToCheck = sizeof(SlotsToCheck)/sizeof(SlotsToCheck[0]);
u32 CurSlot = 0;
for (; CurSlot<NumSlotsToCheck; CurSlot++)
{
if (SlotsToCheck[CurSlot] == ActiveSlot) break;
};
if (CurSlot >= NumSlotsToCheck)
CurSlot = NumSlotsToCheck-1; //last in row
for (s32 i=s32(CurSlot-1); i>=0; i--)
{
if (inventory().ItemFromSlot(SlotsToCheck[i]))
{
if (SlotsToCheck[i] == ARTEFACT_SLOT)
{
IR_OnKeyboardPress(kARTEFACT);
}
else
IR_OnKeyboardPress(kWPN_1 + i);
return;
}
}
};
示例12: updateCurrentViewStack
void EventSystem::propagateMouseEvent(Event* event)
{
updateCurrentViewStack(event);
if(currentViewStack.size() == 0) { return; } // bail if no views, happens when mouse outside of window
// logViewStack(currentViewStack);
event->base.bubbles = true;
event->base.stopDispatch = false;
event->base.stopPropagation = false;
EventType et = event->base.type;
if((et == ET_MouseUp) || (et == ET_MouseDown))
{
propagateUpDownEvent(event);
if(et == ET_MouseDown)
{
propagateFocusEvent(event);
}
}
else
{
// propagate scroll/move
event->base.target = currentViewStack.back();
s32 targetIndex = s32(currentViewStack.size())-1;
propagateEvent(currentViewStack, event, targetIndex);
}
// enter/leave
if(et == ET_MouseMove)
{
propagateEnterLeaveEvent(event);
previousMouseMoveStack = currentViewStack;
}
}
示例13: is_good_motion
bool CMotionStats::is_good_motion(u32 elems_checked)
{
u32 from_index;
u32 to_index;
if (index == 0) return true;
else from_index = index-1;
if (s32(index - elems_checked) < 0) return true;
else to_index = index - elems_checked;
bool bGood = true;
float test_speed = _data[from_index].speed;
for (u32 i=from_index; i>to_index;i--) {
// считать только, если все элементы содержат одинаковые скорости
if (!fsimilar(test_speed,_data[i].speed)) break;
float cur_dist = _data[i].position.distance_to(_data[i-1].position);
TTime delta_t = _data[i].time - _data[i-1].time;
float speed = cur_dist * 1000.f / float(delta_t);
if (fsimilar(_data[i-1].speed,0.0f)) continue;
if (speed * 5.f < _data[i].speed) {
bGood = false;
break;
}
}
return bGood;
}
示例14: s32
void PPCXEmitter::BLE (const void *fnptr) {
CHECK_SMALL_JUMP
s32 func = (s32)fnptr - s32(code);
u32 instr = (0x40810000 | (((s16)(((func)+1))) & 0xfffc));
Write32(instr);
}
示例15: defined
// This method needs a properly cleaned error state before the checked instruction is called
bool COpenGLShaderMaterialRenderer::checkError(const irr::c8* type)
{
#if defined(GL_ARB_vertex_program) || defined(GL_NV_vertex_program) || defined(GL_ARB_fragment_program) || defined(GL_NV_fragment_program)
GLenum g = glGetError();
if (g == GL_NO_ERROR)
return false;
core::stringc errString = type;
errString += " compilation failed";
errString += " at position ";
GLint errPos=-1;
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos );
#else
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos );
#endif
errString += core::stringc(s32(errPos));
errString += ":\n";
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_ARB));
#else
errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_NV));
#endif
#else
core::stringc errString("Shaders not supported.");
#endif
os::Printer::log(errString.c_str(), ELL_ERROR);
return true;
}