VStringInputMap* VStringInputMapManager::GetInstance(unsigned int iIndex) const { VASSERT(iIndex < (unsigned int)m_instances.GetSize()); return m_instances[iIndex]; }
void VTimeOfDayComponent::UpdateParent() { VTimeOfDay *pTimeOfDayInterface = (VTimeOfDay*)Vision::Renderer.GetTimeOfDayHandler(); if (pTimeOfDayInterface == NULL) return; VisObject3D_cl *pOwnerObject = (VisObject3D_cl *)m_pOwner; VASSERT(pOwnerObject); hkvVec3 vDirection(hkvNoInitialization); pTimeOfDayInterface->GetSunDirection(vDirection); // The Moon and back light direction is calculated from the Sun direction if (AttachmentType == TIMEOFDAY_ATTACHMENT_MOONLIGHTSOURCE) { vDirection = -vDirection; } else if(AttachmentType == TIMEOFDAY_ATTACHMENT_SUNBACKLIGHTSOURCE) { vDirection.x = -vDirection.x; vDirection.y = -vDirection.y; } if (AttachmentType != TIMEOFDAY_ATTACHMENT_ENABLEDATNIGHTLIGHTSOURCE) { pOwnerObject->SetDirection(vDirection); } if (AttachmentType == TIMEOFDAY_ATTACHMENT_CORONALIGHTSOURCE) { // TODO (multiple renderer nodes) IVRendererNode *pRenderer = Vision::Renderer.GetRendererNode(0); float fNear, fFar; pRenderer->GetReferenceContext()->GetClipPlanes(fNear, fFar); hkvVec3 vCamPos = pRenderer->GetReferenceContext()->GetCamera()->GetPosition(); hkvVec3 vCoronaPos = -vDirection; vCoronaPos *= 0.95f * fFar; vCoronaPos += vCamPos; pOwnerObject->SetPosition(vCoronaPos); } // Set the color and intensity of the light if (m_bIsLightClass) { VisLightSource_cl *pLight = (VisLightSource_cl*)m_pOwner; VColorRef color; float intensity = 0.0f; switch (AttachmentType) { case TIMEOFDAY_ATTACHMENT_ENABLEDATNIGHTLIGHTSOURCE: { color = m_iColor; const float fMarginNearHorizon = 0.1f; //10% - Margin above the horizon to switch lights ON/OFF const float fBelowHorizonMultiplier = hkvMath::Max(-vDirection.z + fMarginNearHorizon, 0.0f); intensity = 1.0f - hkvMath::Min(1.0f, fBelowHorizonMultiplier); break; } case TIMEOFDAY_ATTACHMENT_CORONALIGHTSOURCE: { color = pTimeOfDayInterface->GetSunColor(); hkvVec3 vSunColorFloat = color.ToFloat(); float fLargestComponent = hkvMath::Max(hkvMath::Max(vSunColorFloat.x, vSunColorFloat.y), vSunColorFloat.z); if (fLargestComponent > 0.0f) { color.FromFloat(vSunColorFloat / fLargestComponent); } intensity = 0.0f; break; } case TIMEOFDAY_ATTACHMENT_SUNLIGHTSOURCE: { color = pTimeOfDayInterface->GetSunColor(); intensity = pTimeOfDayInterface->GetSunIntensity(); break; } case TIMEOFDAY_ATTACHMENT_SUNBACKLIGHTSOURCE: { color = pTimeOfDayInterface->GetBackLightColor(); intensity = pTimeOfDayInterface->GetBackLightIntensity(); break; } case TIMEOFDAY_ATTACHMENT_MOONLIGHTSOURCE: { color = pTimeOfDayInterface->GetMoonColor(); intensity = pTimeOfDayInterface->GetMoonIntensity(); break; } default: VASSERT_MSG(0,"Unknown time of day attachment type"); } pLight->SetColor(color); pLight->SetMultiplier(intensity * Intensity); } }
VGUIManager *VWindowBase::GetMenuManager() const { VASSERT(m_pContext); return m_pContext->GetManager(); }
void VStringInputMapManager::RemoveInstance(unsigned int iIndex) { VASSERT(iIndex < (unsigned int)m_instances.GetSize()); m_instances[iIndex] = NULL; }
/// \brief /// Removes this element instance from the element manager inline void RemoveFromElementManager() {VASSERT(m_iListIndex!=VIS_INVALID && ElementManagerGet(m_iListIndex)==((ELEMTYPE)this));ElementManagerRemove(m_iListIndex);m_iListIndex=(unsigned int)-1;}
int main(int argc, char *argv[]) { int i, testi, testj; int myrank; int nproc; char string[100]; Vcom *vcom; VASSERT( Vcom_init(&argc,&argv) ); vcom = Vcom_ctor(1); myrank = Vcom_rank(vcom); nproc = Vcom_size(vcom); printf("PE %d: Starting test program with %d total PEs.\n",myrank,nproc); /* Character send/recv test */ if (myrank == 0) { printf("\n\nPE %d: STARTING SEND/RECV TEST.\n",myrank); printf("PE %d: Sending non-blocked messages.\n",myrank); for (i=1; i<nproc; i++) { sprintf(&(string[0]), "non-blocked message (PE %d --> %d)", myrank, i); printf( "PE %d: Sent non-blocked message to PE %d\n", myrank, i); assert(Vcom_send(vcom,i,string,100,3,0)); } printf("PE %d: Sending blocked messages.\n",myrank); for (i=1; i<nproc; i++) { sprintf(&(string[0]),"blocked message (PE %d --> %d)",i,nproc); printf( "PE %d: Sent blocked message to PE %d\n", myrank, i); assert(Vcom_send(vcom,i,string,100,3,1)); } } else { printf("PE %d: Recving blocked message from PE 0.\n",myrank); /* Get blocked sent messages */ assert(Vcom_recv(vcom,0,string,100,3,1)); printf( "PE %d: Blocked message is: '%s'\n",myrank,string); /* Get blocked sent messages */ printf("PE %d: Recving non-blocked message from PE 0.\n",myrank); assert(Vcom_recv(vcom,0,string,100,3,1)); printf( "PE %d: Non-blocked message is: '%s'\n",myrank,string); } fflush(stdout); Vcom_barr(vcom); /* Barrier test */ if (myrank == 0) printf("\n\nPE %d: STARTING BARRIER TEST.\n",myrank); printf("PE %d: Hit barrier\n", myrank); Vcom_barr(vcom); printf("PE %d: Passed barrier\n", myrank); fflush(stdout); Vcom_barr(vcom); /* getCount test */ if (myrank == 0) { printf("\n\nPE %d: STARTING PROBE TEST.\n",myrank); printf("PE %d: Sending string of length 100\n", myrank); for (i=1; i<nproc; i++) assert(Vcom_send(vcom,i,string,100,3,0)); } else { Vcom_getCount(vcom, 0, &testi, 3); printf("PE %d: Probed for string of length %d\n", myrank, testi); } fflush(stdout); Vcom_barr(vcom); /* Reduction test */ testi = 4; if (myrank == 0) { printf("\n\nPE %d: STARTING REDUCTION TEST.\n",myrank); printf("PE %d: All %d PEs have the number %d.\n", myrank, nproc, testi); printf("PE %d: Performing global sum reduction.\n", myrank); } Vcom_reduce(vcom, &testi, &testj, 1, 1, 0); printf("PE %d: Global sum = %d\n", myrank, testj); fflush(stdout); Vcom_barr(vcom); testi = 4; if (myrank == 0) { testj = 8; printf("PE %d: PE %d has the number %d; all others have %d.\n", myrank, myrank, testj, testi); testi = testj; printf("PE %d: Performing global max reduction.\n", myrank); } Vcom_reduce(vcom, &testi, &testj, 1, 1, 3); printf("PE %d: Global max = %d\n", myrank, testj); fflush(stdout); Vcom_barr(vcom); /* Resize the communicator */ printf("PE %d: Resizing communicator from %d to %d.\n", myrank, nproc, (int)(nproc/2)); Vcom_resize(vcom, (int)(nproc/2)); myrank = Vcom_rank(vcom); if (Vcom_rank(vcom) != -1) printf("PE %d: Hello world from resized communicator\n", myrank); Vcom_barr(vcom); /* Finish up */ printf("PE %d: Exiting test program.\n",myrank); fflush(stdout); Vcom_dtor(&vcom); VASSERT( Vcom_finalize() ); return 0; }
/** Install and Uninstall the service and write actions to the event log. If pszFullPath is given, it will be set as the path, otherwise the path will be retreived from the module name. The default command line processing calls this function with pszLogonAs and pszLogonPassword set to NULL. Override this function, and when bInstall is VTRUE, get the logon as and password if needed, and then call the base class function. pszLogonAs can be either a DomainName\UserName or just the UserName, in which case this function will prepend .\ which is required by the CreateService() API function. Returns VTRUE on success, VFALSE on failure.*/ virtual VBOOL Install( VBOOL bInstall = VTRUE, VDWORD nStartType = SERVICE_AUTO_START, VSTRING_CONST pszFullPath = NULL, VSTRING_CONST pszLogonAs = NULL, VSTRING_CONST pszLogonPassword = NULL, VBOOL bStartAfterInstall = VTRUE, VBOOL bSilentMode = VFALSE) { /* Service name should not be empty!*/ VASSERT(m_strServiceName.IsNotEmpty()) /* Assume failure.*/ VBOOL bSuccess = VFALSE; /* Open the Service Control Manager.*/ SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if ( hSCM ) { if ( bInstall ) { /* Verify un-installed, first (silent mode).*/ Install(VFALSE, 0, NULL, NULL, NULL, VFALSE, VTRUE); /* Get this executables file path (unless given in pszFullPath).*/ VString sPath; if ( !pszFullPath ) sPath.GetModulePath(VFALSE, VFALSE); else sPath = pszFullPath; if ( sPath.IsNotEmpty() ) { /* If pszLogonAs is not NULL, verify domain name is present, and if not, .\ is present. If neither is the case, we will modify the logon as to be correct.*/ VString strLogonAs; if ( pszLogonAs ) { /* If we find a \ assume correct DomainName\UserName string.*/ if ( !VSTRCHR(pszLogonAs, VTEXT('\\')) ) { /* Domain Name not given, so does the string already contain .\ sequence as the first chars?*/ if ( !(*pszLogonAs == VTEXT('.') && *(pszLogonAs + 1) == VTEXT('\\')) ) { strLogonAs = VTEXT(".\\"); strLogonAs += pszLogonAs; pszLogonAs = strLogonAs; } } } /* We want no error condition now.*/ SetLastError(0); /* Create the service.*/ SC_HANDLE hService = CreateService( hSCM, m_strServiceName, m_strServiceName, SERVICE_ALL_ACCESS, m_Status.dwServiceType, nStartType, SERVICE_ERROR_NORMAL, sPath, NULL, NULL, NULL, pszLogonAs, pszLogonPassword); if ( hService || GetLastError() == ERROR_SERVICE_EXISTS ) { /* Make or verify registry entries to support event logging.*/ bSuccess = (m_hEventSource) ? VTRUE : Register(m_strServiceName); if ( hService && bSuccess && bStartAfterInstall ) { bSuccess = StartService(hService, 0, NULL); /* If service fails to start now, un-install it.*/ if ( !bSuccess ) { /* Close handle first.*/ CloseServiceHandle(hService); hService = NULL; /* Un-Install in silent mode.*/ Install( VFALSE, 0, NULL, NULL, NULL, VFALSE, VTRUE); } } if ( hService ) CloseServiceHandle(hService); } } /* Log what happened if we can.*/ LogEvent( (bSuccess) ? EM_SERVICE_INSTALLED : EM_SERVICE_NOT_INSTALLED, (bSuccess) ? VFALSE : VTRUE); /* Notify via virtual function.*/ OnInstall(bSuccess, bSilentMode); } else { SC_HANDLE hService = OpenService( hSCM, m_strServiceName, SERVICE_QUERY_STATUS | DELETE); if ( hService ) { /* If the service is running, stop it.*/ SERVICE_STATUS ss; if ( QueryServiceStatus(hService, &ss) ) { if ( ss.dwCurrentState != SERVICE_STOPPED ) { /* Get a handle we can use to stop the service.*/ SC_HANDLE hStopService = OpenService( hSCM, m_strServiceName, SERVICE_STOP); if ( hStopService ) { SERVICE_STATUS ss; ControlService( hStopService, SERVICE_CONTROL_STOP, &ss); CloseServiceHandle(hStopService); } } } bSuccess = (hService && DeleteService(hService)) ? VTRUE : VFALSE; CloseServiceHandle(hService); } else bSuccess = VTRUE; /* Remove registry entries on success.*/ if ( bSuccess ) { VRegistry reg; if ( reg.CreateKey(GetRegistryKey(), HKEY_LOCAL_MACHINE) ) reg.DeleteSubKeyNT(m_strServiceName); } /* Log what happened if we can.*/ LogEvent( (bSuccess) ? EM_SERVICE_UNINSTALLED : EM_SERVICE_NOT_REMOVED, (bSuccess) ? VFALSE : VTRUE); /* Notify via virtual function.*/ OnUnInstall(bSuccess, bSilentMode); } CloseServiceHandle(hSCM); } return bSuccess; }
/// \brief /// Adds this element instance to the element manager. /// /// Sets the m_iListIndex member accordingly. inline void AddToElementManager() {VASSERT(m_iListIndex==(unsigned int)-1);m_iListIndex=ElementManagerAdd((ELEMTYPE)this);}
void VTerrainSectorMeshPageInfo::SerializeX(VTerrainSector *pOwner, VArchive &ar, int iLocalVersion) { if (ar.IsLoading()) { if(iLocalVersion >= SECTOR_FILE_VERSION_21) { char magic[4]; ar.Read(magic, 4); VASSERT(magic[0] == 0x50); VASSERT(magic[1] == 0x61); VASSERT(magic[2] == 0x67); VASSERT(magic[3] == 0x65); } ar.Read(m_fLODThreshold,(MAX_MESH_LOD-1)*sizeof(float),"f",(MAX_MESH_LOD-1)); ar >> m_bHasHoles >> m_bAllHoles; if (m_bHasHoles && !m_bAllHoles) { short iLevels; ar >> iLevels; VASSERT(iLevels == pOwner->m_Config.m_iMaxMeshLODHoles+1); for (int i=0;i<iLevels;i++) m_HoleLODInfo[i].SerializeX(ar,iLocalVersion); m_spHoleIndexBuffer = new VisMeshBuffer_cl(); m_spHoleIndexBuffer->SetResourceFlag(VRESOURCEFLAG_AUTODELETE); #ifdef HK_DEBUG m_spHoleIndexBuffer->SetFilename("<TerrainHoleIndexBuffer>"); #endif m_spHoleIndexBuffer->SerializeX(ar); } if(iLocalVersion >= SECTOR_FILE_VERSION_21) { char iTextureType; VTextureObject* pLayer[16]; for (int i=0;i<16;i++) { ar >> iTextureType; switch (iTextureType) { case SECTOR_TEXTURETYPE_NULL : pLayer[i] = pOwner->GetSectorManager()->GetPlainBlackTexture();break; // this is a "real" black texture with alpha==0 case SECTOR_TEXTURETYPE_WHITE : pLayer[i] = Vision::TextureManager.GetPlainWhiteTexture();break; case SECTOR_TEXTURETYPE_BLACK : pLayer[i] = Vision::TextureManager.GetPlainBlackTexture();break; // this one has alpha==255 case SECTOR_TEXTURETYPE_FILE : pLayer[i] = VTextureObject::DoArchiveExchange(ar, NULL);break; case SECTOR_TEXTURETYPE_NEUTRALNORMAL: pLayer[i] = Vision::TextureManager.GetNeutralNormalMapTexture();break; default: VASSERT(!"Invalid texture type. File corrupt?"); } if (pLayer[i]) // valid for all types of texture pLayer[i]->SetResourceFlag(VRESOURCEFLAG_AUTODELETE); SetTextureBySamplerIndex(pLayer[i], i); } ar >> m_iSamplerClampMask; int iRegCountInFile; ar >> iRegCountInFile; m_iPixelShaderRegCount = hkvMath::Max(iRegCountInFile,6); #if defined(_VR_DX11) m_SectorPSConstBuffer.AllocateBuffer(0,m_iPixelShaderRegCount*sizeof(hkvVec4)); #endif hkvVec4* pPixelConst = LockPixelConst(); ar.Read(pPixelConst,iRegCountInFile*sizeof(hkvVec4),"ffff",iRegCountInFile); UpdateNormalmapRegister (pPixelConst); UnLockPixelConst(); ar >> m_iNumThreeWayMappingLayer; if (m_iNumThreeWayMappingLayer > 0) { ar >> m_iThreeWayMappingLayerMask; }
void VTimeOfDayComponent::UpdateParent() { IVTimeOfDay *pTimeOfDayInterface = Vision::Renderer.GetTimeOfDayHandler(); if (pTimeOfDayInterface == NULL) return; VisObject3D_cl *pOwnerObject = (VisObject3D_cl *)m_pOwner; VASSERT(pOwnerObject); hkvVec3 vDirection(hkvNoInitialization); pTimeOfDayInterface->GetSunDirection(vDirection); vDirection.normalizeIfNotZero(); if (AttachmentType == TIMEOFDAY_ATTACHMENT_MOONLIGHTSOURCE) { vDirection = -vDirection; } else if(AttachmentType == TIMEOFDAY_ATTACHMENT_SUNBACKLIGHTSOURCE) { vDirection.x = -vDirection.x; vDirection.y = -vDirection.y; } if (AttachmentType != TIMEOFDAY_ATTACHMENT_ENABLEDATNIGHTLIGHTSOURCE) { pOwnerObject->SetDirection(vDirection); } if (AttachmentType == TIMEOFDAY_ATTACHMENT_CORONALIGHTSOURCE) { // TODO (multiple renderer nodes) IVRendererNode *pRenderer = Vision::Renderer.GetRendererNode(0); float fNear, fFar; pRenderer->GetReferenceContext()->GetClipPlanes(fNear, fFar); hkvVec3 vCamPos = pRenderer->GetReferenceContext()->GetCamera()->GetPosition(); hkvVec3 vCoronaPos = -vDirection; vCoronaPos *= 0.95f * fFar; vCoronaPos += vCamPos; pOwnerObject->SetPosition(vCoronaPos); } if (m_bIsLightClass) { VisLightSource_cl *pLight = (VisLightSource_cl*)m_pOwner; VColorRef sunColor = pTimeOfDayInterface->GetSunColor(); bool bSwitchable = (AttachmentType == TIMEOFDAY_ATTACHMENT_ENABLEDATNIGHTLIGHTSOURCE); float fBelowHorizonMultiplier = hkvMath::pow (hkvMath::Max(-vDirection.z+0.1f, 0.0f), bSwitchable ? 1.0f : 0.1f); fBelowHorizonMultiplier = hkvMath::Min(1.0f, fBelowHorizonMultiplier); if (bSwitchable && fBelowHorizonMultiplier < 1.0f && fBelowHorizonMultiplier > 0.f) { pLight->SetColor(m_iColor); pLight->SetMultiplier(Intensity * (1.0f - fBelowHorizonMultiplier)); } else if (AttachmentType == TIMEOFDAY_ATTACHMENT_SUNLIGHTSOURCE) { pLight->SetColor(sunColor); pLight->SetMultiplier(Intensity * fBelowHorizonMultiplier); } else if ((AttachmentType == TIMEOFDAY_ATTACHMENT_MOONLIGHTSOURCE) || (AttachmentType == TIMEOFDAY_ATTACHMENT_SUNBACKLIGHTSOURCE)) { // TODO VColorRef negativeColor = V_RGBA_WHITE - sunColor; pLight->SetColor(negativeColor); pLight->SetMultiplier(Intensity * fBelowHorizonMultiplier * 0.333f); } else if (AttachmentType == TIMEOFDAY_ATTACHMENT_CORONALIGHTSOURCE) { hkvVec3 vSunColorFloat = sunColor.ToFloat(); float fLargestComponent = hkvMath::Max(hkvMath::Max(vSunColorFloat.x, vSunColorFloat.y), vSunColorFloat.z); if (fLargestComponent <= 0.0f) fLargestComponent = 1.0f; sunColor.FromFloat(vSunColorFloat * (1.0f / fLargestComponent)); pLight->SetColor(sunColor * fBelowHorizonMultiplier); pLight->SetMultiplier(0.0f); } } }
/// \brief /// Calls TriggerCallbacks on the sender member and passes this data object. /// \note /// Can only be called successfully if a valid sender has been passed when constructing /// this data object. If this isn't the case, an assertion will be raised and the callback /// will not be triggered. inline void Trigger() { VASSERT(m_pSender!=NULL); if (m_pSender) m_pSender->TriggerCallbacks(this); }
/// \brief /// Indicates whether the passed handler is registered to this callback /// /// \param pHandler /// A handler to test /// /// \return /// \c TRUE if handler is registered in this callback; \c FALSE if not /// /// \sa VCallback::RegisterCallback /// \sa VCallback::TriggerCallbacks /// \sa class IVisCallbackHandler_cl inline BOOL IsRegistered(IVisCallbackHandler_cl *pHandler) {VASSERT(pHandler);return GetElementPos(pHandler)>=0;}
bool SpriteData::GenerateConvexHull() { bool success = false; #if defined(WIN32) && USE_HAVOK_PHYSICS_2D const int bytesPerPixel = spriteSheetTexture->GetBitsPerPixel(spriteSheetTexture->GetTextureFormat()) / 8; IDirect3DTexture9 *pTexture2D = (IDirect3DTexture9 *)spriteSheetTexture->GetD3DInterface(); const int iMipLevel = 0; const int iLockFlags = D3DLOCK_READONLY; D3DLOCKED_RECT destRect; RECT lockRect = { 0, 0, spriteSheetTexture->GetTextureWidth(), spriteSheetTexture->GetTextureHeight() }; HRESULT result = pTexture2D->LockRect(iMipLevel, &destRect, NULL, spriteSheetTexture->GetD3D9LockFlags(iLockFlags)); if (result == S_OK) { const unsigned char thresholdMin = 10; unsigned char *pDest = (unsigned char *)destRect.pBits; for (int stateIndex = 0; stateIndex < cells.GetLength(); stateIndex++) { SpriteCell &cell = cells[stateIndex]; const int width = static_cast<int>(cell.width); const int height = static_cast<int>(cell.height); int *mins = new int[height]; int *maxs = new int[height]; memset(mins, -1, sizeof(int) * height); memset(maxs, -1, sizeof(int) * height); const int startX = static_cast<int>(cell.offset.x); const int endX = startX + width; const int startY = static_cast<int>(cell.offset.y); const int endY = startY + height; for (int y = startY; y < endY; y++) { bool findMin = true; const int positionY = y - startY; for (int x = startX; x < endX; x++) { unsigned char *pixelRaw = &pDest[y * destRect.Pitch + x * bytesPerPixel]; unsigned int alpha = 0; // if there's an alpha channel, just worry about that if (bytesPerPixel == 4) { const unsigned int *pixel = reinterpret_cast<unsigned int*>(pixelRaw); alpha = ((*pixel) & 0xff000000) >> 24; } else { for (int offset = 0; offset < bytesPerPixel; offset++) { alpha += pixelRaw[offset]; } } const int positionX = x - startX; const bool withinThreshold = (alpha >= thresholdMin); if (findMin && withinThreshold) { mins[positionY] = positionX; findMin = false; } else if (!findMin && !withinThreshold) { maxs[positionY] = positionX; break; } } if (maxs[positionY] == -1) { maxs[positionY] = width; } } const float hwidth = static_cast<float>(width) / 2.0f; const float hheight = static_cast<float>(height) / 2.0f; hkArray<hkVector4> vertices; for (int y = 0; y < height; y++) { if (mins[y] != -1) { hkReal xx1 = static_cast<hkReal>(mins[y]) - hwidth; hkReal xx2 = static_cast<hkReal>(maxs[y]) - hwidth; hkReal hh = static_cast<hkReal>(y) - hheight; vertices.pushBack( hkVector4(xx1, hh, 0, 0) ); vertices.pushBack( hkVector4(xx2, hh, 0, 0) ); if (y == height - 1) { hkReal hh2 = static_cast<hkReal>(y + 1) - hheight; vertices.pushBack( hkVector4(xx1, hh2, 0, 0) ); vertices.pushBack( hkVector4(xx2, hh2, 0, 0) ); } } } delete [] mins; delete [] maxs; const bool sortInputs = true; const bool simplify = false; hkgpConvexHull::BuildConfig config; config.m_allowLowerDimensions = true; config.m_buildIndices = true; config.m_sortInputs = sortInputs; hkVector4 projectionPlane(0, 0, 1); hkgpConvexHull convexHull; if ( convexHull.build(vertices, config) != -1 ) { hkgpConvexHull *result = &convexHull; result->generateIndexedFaces(hkgpConvexHull::INTERNAL_VERTICES, cell.verticesPerFace, cell.vertexIndices, true); result->fetchPositions(hkgpConvexHull::INTERNAL_VERTICES, cell.vertexPositions); hkpConvexVerticesShape::BuildConfig config; config.m_convexRadius = 0.0f; config.m_shrinkByConvexRadius = false; config.m_useOptimizedShrinking = false; cell.shape = new hkpConvexVerticesShape(cell.vertexPositions, config); const hkReal depth = 100.0f; // Generate a 3d hkArray<hkVector4> vertexPositions3d; for (int vertexIndex = 0; vertexIndex < cell.vertexPositions.getSize(); vertexIndex++) { const hkVector4 position = cell.vertexPositions[vertexIndex]; vertexPositions3d.pushBack( hkVector4(position(0), position(1), 0.0f, 0.0f) ); } // Get the bounding box of the shape and use the max extent as the depth of the 3d shape hkAabb aabb; cell.shape->getAabb( hkTransform::getIdentity(), 0.f, aabb ); const hkReal depthCenter = depth * 1.3f; hkVector4 center; aabb.getCenter(center); vertexPositions3d.pushBack( hkVector4(center(0), center(1), -depthCenter , 0.f) ); vertexPositions3d.pushBack( hkVector4(center(0), center(1), depthCenter , 0.f) ); config.m_convexRadius = 0.05f; config.m_shrinkByConvexRadius = false; cell.shape3d = new hkpConvexVerticesShape(vertexPositions3d, config); success = true; } } HRESULT unlockResult = pTexture2D->UnlockRect(iMipLevel); VASSERT(unlockResult == S_OK); }
void RPG_Action_RangedAttack::Tick(float const deltaTime) { RPG_Action_AttackBase::Tick(deltaTime); if(m_attacking) { // RangedAttacking was set to true when the action was initiated. Is reset to false by Behavior when the attack anim finishes. vHavokBehaviorComponent *const behaviorComponent = m_characterOwner->GetBehaviorComponent(); VVERIFY_OR_RET(behaviorComponent); VASSERT(!m_behaviorTriggerVarName.IsEmpty()); if (!RPG_VisionHavokBehaviorHelper::BehaviorGetVarNamed<bool>(*behaviorComponent, m_behaviorTriggerVarName.AsChar())) { if (m_flags == 1) { if(m_updatedInteraction) { m_updatedInteraction = false; if(!m_updatedInteractionEntity && m_interactionEntity) { // Do not lose the player's intended target ValidateInteractionEntity(); if(!m_interactionEntity->Components().GetComponentOfType(V_RUNTIME_CLASS(RPG_AttackableComponent))) { m_interactionEntity = NULL; } else { if(m_interactionEntity->GetPosition().getDistanceToSquared(m_updatedInteractionPosition) > s_retargetingRadius * s_retargetingRadius) { m_interactionEntity = NULL; } } } else { m_interactionEntity = m_updatedInteractionEntity; ValidateInteractionEntity(); } m_interactionPosition = m_updatedInteractionPosition; } m_startTime = Vision::GetTimer()->GetTime(); StartAttack(); } else { // if we've gotten to the end and haven't fired the projectile, fire it now if (!m_hasFired) { VString msg; msg.Format("RPG_Action_RangedAttack never received expected %s event from Behavior.", m_behaviorFireEventName.AsChar()); Vision::Error.Warning(msg.AsChar()); //VASSERT_MSG(false, msg.AsChar()); FireAttack(); } End(); } } else { // we're currently attacking hkvVec3 const targetPosition = m_interactionEntity ? m_interactionEntity->GetPosition() : m_interactionPosition; FaceTargetPoint(targetPosition); #ifdef _DEBUG if (m_debugDisplayInfo) { Vision::Game.DrawSingleLine(m_characterOwner->GetPosition(), targetPosition, VColorRef(255, 0, 255)); } #endif } } else { StartAttack(); } }
/// \brief /// Sets a LOD bias sepcifically for mirror/water rendering. If this is 1.0 (default) terrain will be rendered with one LOD level up /// runtime. The default is 1.0 inline void SetLODMirrorBias(float fValue=1.0f) { VASSERT(fValue>=0.f); fValue = hkvMath::Min(fValue,(float)m_Config.m_iMaxMeshLODHoles-0.5f); m_SectorManager.m_fMirrorLODBias = fValue; }