static bln ShowMessageCmd( const CArguments *args ) { if( !args ) { ::MessageBoxA( 0, 0, 0, 0 ); return true; } ui32 len = 0; for( ui32 index = 0; index < args->Size(); ++index ) { if( args->MaskS( index, 's' ) ) { len += args->AgsLength( index ) + 1; } } char *p_buf = (char *)ALLOCA( len ); len = 0; for( ui32 index = 0; index < args->Size(); ++index ) { if( args->MaskS( index, 's' ) ) { _MemCpy( p_buf + len, args->AgS( index ), args->AgsLength( index ) ); len += args->AgsLength( index ); p_buf[ len++ ] = ' '; } } p_buf[ len - 1 ] = '\0'; ::MessageBoxA( 0, p_buf, "Message With Ags", 0 ); return true; }
void CCamera::Update() { LiceMath::Vec3NormalizeInplace( &_o_zvec ); LiceMath::Vec3Cross( &_o_yvec, &_o_zvec, &_o_xvec ); LiceMath::Vec3NormalizeInplace( &_o_yvec ); LiceMath::Vec3Cross( &_o_xvec, &_o_yvec, &_o_zvec ); LiceMath::Vec3NormalizeInplace( &_o_xvec ); _o_view.e00 = _o_xvec.x; _o_view.e10 = _o_xvec.y; _o_view.e20 = _o_xvec.z; _o_view.e01 = _o_yvec.x; _o_view.e11 = _o_yvec.y; _o_view.e21 = _o_yvec.z; _o_view.e02 = _o_zvec.x; _o_view.e12 = _o_zvec.y; _o_view.e22 = _o_zvec.z; _o_view.e30 = -LiceMath::Vec3Dot( &_o_xvec, &_o_position ); _o_view.e31 = -LiceMath::Vec3Dot( &_o_yvec, &_o_position ); _o_view.e32 = -LiceMath::Vec3Dot( &_o_zvec, &_o_position ); LiceMath::M4x3AsM4x4LastIdenMultM4x4( &_o_viewProj, &_o_view, &_o_proj ); LiceMath::M4x4Transpose( &_o_viewProjTransp, &_o_viewProj ); LiceMath::M4x3Transpose( &_o_viewTransp, &_o_view ); vec4 o_col0( _o_viewProj.e00, _o_viewProj.e10, _o_viewProj.e20, _o_viewProj.e30 ); vec4 o_col1( _o_viewProj.e01, _o_viewProj.e11, _o_viewProj.e21, _o_viewProj.e31 ); vec4 o_col2( _o_viewProj.e02, _o_viewProj.e12, _o_viewProj.e22, _o_viewProj.e32 ); vec4 o_col3( _o_viewProj.e03, _o_viewProj.e13, _o_viewProj.e23, _o_viewProj.e33 ); LiceMath::Vec4Addition( (vec4 *)&_ao_frustum[ 0 ], &o_col3, &o_col0 ); // left LiceMath::Vec4Subtract( (vec4 *)&_ao_frustum[ 1 ], &o_col3, &o_col0 ); // right LiceMath::Vec4Subtract( (vec4 *)&_ao_frustum[ 2 ], &o_col3, &o_col1 ); // top LiceMath::Vec4Addition( (vec4 *)&_ao_frustum[ 3 ], &o_col3, &o_col1 ); // bottom LiceMath::Vec4Subtract( (vec4 *)&_ao_frustum[ 5 ], &o_col3, &o_col2 ); // far _MemCpy( &_ao_frustum[ 4 ], &o_col2, sizeof(vec4) ); // near for( i32 i = 0; i < 6; ++i ) { LiceMath::PlaneNormalizeInplace( &_ao_frustum[ i ] ); _a_frustumLook[ i ][ 0 ] = _ao_frustum[ i ].a < 0.f; _a_frustumLook[ i ][ 1 ] = _ao_frustum[ i ].b < 0.f; _a_frustumLook[ i ][ 2 ] = _ao_frustum[ i ].c < 0.f; } }
NOINLINE void CommandsManager::AddComplexCommand( const char *cp_name, ui32 category, const char *cp_desc, const void *cp_param, uiw paramSize, executorfunc executor ) { ASSUME( cp_name && category != WrongCategory && cp_param && paramSize && executor ); if( IsCommandExist( cp_name ) ) { SENDLOG( CLogger::Tag::error, "CommandsManager::AddCommand command %s already exists\n", cp_name ); return; } ui32 nameLen = _StrLen( cp_name ) + 1; o_Commands.Resize( o_Commands.Size() + 1 ); SCommand &o_cmd = o_Commands.Back(); o_cmd.executeFunc = executor; o_cmd.category = category; o_cmd.name = cp_name; o_cmd.desc = cp_desc; o_cmd.param.Resize( paramSize ); _MemCpy( o_cmd.param.Data(), cp_param, paramSize ); }
static void MemCopy( TYPE& to, const TYPE& from ) { _MemCpy(&to, &from, sizeof(TYPE)); }
static void MemCopy( TYPE* to, const TYPE* from, ULong count=1 ) { _MemCpy(to, from, count * sizeof(TYPE)); }
void CHalos::Draw( bln is_stepTwo ) { if( _o_halos.Size() == 0 || _o_mats.Size() < 1 || (!_is_occlude && _visibleHalos == 0) || !is_stepTwo ) { return; } ASSUME( _i_vbDraw ); if( _is_occlude ) { ui32 queriesCount = 0; for( ui32 halo = 0; halo < _o_halos.Size(); ++halo ) { if( !_o_halos[ halo ].testObject ) { continue; } CObjectBase *obj = _o_halos[ halo ].testObject; if( !obj->IsInFrustumGet() || !obj->IsGlowingGet() ) { continue; } if( _o_oqueries.Size() <= queriesCount ) { ASSUME( _o_oqueries.Size() + 1 > queriesCount ); _o_oqueries.Resize( _o_oqueries.Size() + 1 ); D3D11_QUERY_DESC o_queryDesc; o_queryDesc.Query = D3D11_QUERY_OCCLUSION; o_queryDesc.MiscFlags = 0; DXHRCHECK( RendererGlobals::i_Device->CreateQuery( &o_queryDesc, _o_oqueries[ queriesCount ].i_query.AddrModifiable() ) ); } _o_oqueries[ queriesCount ].index = halo; RendererGlobals::i_ImContext->Begin( _o_oqueries[ queriesCount ].i_query ); obj->Draw( true ); RendererGlobals::i_ImContext->End( _o_oqueries[ queriesCount ].i_query ); ++queriesCount; } if( !queriesCount ) { return; } f32 screenSizePixels = RendererGlobals::RenderingWidth * RendererGlobals::RenderingHeight; D3D11_MAPPED_SUBRESOURCE o_sr; DXHRCHECK( RendererGlobals::i_ImContext->Map( _i_vbDraw, 0, D3D11_MAP_WRITE_DISCARD, 0, &o_sr ) ); CVecArr < byte > target( (byte *)o_sr.pData, 0, sizeof( vec4 ) * 4096 ); _visibleHalos = 0; for( ui32 query = 0; query < queriesCount; ++query ) { UINT64 pixels; while( RendererGlobals::i_ImContext->GetData( _o_oqueries[ query ].i_query, &pixels, sizeof(pixels), 0 ) != S_OK ) { } if( !pixels ) { continue; } ui32 index = _o_oqueries[ query ].index; f32 onScreenIntensity = (f32)pixels / screenSizePixels; f32 haloIntensity = _o_halos[ index ].intensity * onScreenIntensity; target.Append( (byte *)&_o_halos[ index ].o_pos, sizeof(vec3) ); target.Append( (byte *)&haloIntensity, sizeof(f32) ); target.Append( (byte *)&_o_halos[ index ].o_color, sizeof(f128color) ); ++_visibleHalos; } RendererGlobals::i_ImContext->Unmap( _i_vbDraw, 0 ); } if( !_visibleHalos ) { return; } for( ui32 mat = 0; mat < _o_mats.Size(); ++mat ) { if( !_o_mats[ mat ].is_geoShaderDefined || !_o_mats[ mat ].is_enabled ) { continue; } if( !_o_mats[ mat ].rstates ) { continue; } RendererGlobals::i_ImContext->IASetInputLayout( _o_mats[ mat ].i_lo ); RendererGlobals::MainBloom.RenderingStatesSet( _o_mats[ mat ].rstates ); D3D11_MAPPED_SUBRESOURCE o_sr; DXHRCHECK( RendererGlobals::i_ImContext->Map( RendererGlobals::ai_VSShaderRegisters[ OBJECT_DATA_BUF ], 0, D3D11_MAP_WRITE_DISCARD, 0, &o_sr ) ); m4x4 o_w = m4x4( _o_w ); LiceMath::M4x4TransposeInplace( &o_w ); _MemCpy( o_sr.pData, &o_w, sizeof(m4x4) ); RendererGlobals::i_ImContext->Unmap( RendererGlobals::ai_VSShaderRegisters[ OBJECT_DATA_BUF ], 0 ); ID3D11Buffer *bufs[ 2 ] = { _o_mats[ mat ].po_geo->i_vbufs[ 0 ], _i_vbDraw }; ui32 offsets[ 2 ] = {}; ui32 strides[ 2 ] = { _o_mats[ mat ].po_geo->strides[ 0 ], sizeof(vec3) + sizeof(f32) + sizeof(f128color) }; RendererGlobals::i_ImContext->IASetVertexBuffers( 0, 2, bufs, strides, offsets ); RendererGlobals::SetPrimitiveTopology( _o_mats[ mat ].po_geo->topo ); RendererGlobals::i_ImContext->OMSetBlendState( _i_blend, 0, 0xFFFFFFFF ); ShadersManager::ApplyShader( _o_mats[ mat ].shader, false ); RendererGlobals::i_ImContext->DrawInstanced( 4, _visibleHalos, 0, 0 ); RendererGlobals::UnbindVBuffers( 0, 2 ); } }