bool InitRobotState( RobotState* out, const RobotModel* model, bool with_velocities, bool with_accelerations) { RobotState robot_state; out->model = model; int mult = 1; if (with_velocities) { ++mult; } if (with_accelerations) { ++mult; } out->values.resize(mult * GetVariableCount(model)); for (int i = 0; i < GetVariableCount(model); ++i) { out->values[i] = GetDefaultPosition(model, GetVariable(model, i)); } double* data = out->values.data(); out->positions = data; data += GetVariableCount(model); if (with_velocities) { out->velocities = data; data += GetVariableCount(model); } if (with_accelerations) { out->accelerations = data; data += GetVariableCount(model); } out->transforms.resize( GetLinkCount(model) + GetJointCount(model) + GetCollisionBodyCount(model) + GetVisualBodyCount(model)); out->link_transforms = out->transforms.data(); out->joint_transforms = out->link_transforms + GetLinkCount(model); out->link_collision_transforms = out->joint_transforms + GetJointCount(model); out->link_visual_transforms = out->link_collision_transforms + GetCollisionBodyCount(model); out->dirty_links_joint = model->root_joint; out->dirty_collisions_joint = model->root_joint; out->dirty_visuals_joint = model->root_joint; return true; }
TEST_F(getLinkCountTest, FilePathNameDoesNotExist) { std::string invalidFile = "/tmp/createFile"; int32_t ret = GetLinkCount(invalidFile.c_str(), &count); ASSERT_EQ(-1, ret); EXPECT_EQ(ENOENT, errno); }
TEST_F(getLinkCountTest, LinkCountOfSinglyLinkedFile) { createFileForTesting(file); int32_t ret = GetLinkCount(file, &count); ASSERT_EQ(0, ret); EXPECT_EQ(1, count); removeFile(file); }
int CNode::Process(CPlayer *pPlayer, int iPointId, int iLastPoint, int iType, CVector3 vecVelocity) { int iChangeNode = 0; // Set the node to the player point SetPoint(iPointId); // Set it to the next link unsigned short usStartLink = GetLinkId(); unsigned short usLinkCount = GetLinkCount(); BYTE byteCount = 0; // Do we need to change the node ? while(!iChangeNode) { // Generate a random link id unsigned short usLinkId = usStartLink + (rand() % usLinkCount); // Set the node to the next random link SetLink(usLinkId); // Keep looping until we get a differente link point while(m_nodeLink.usNodeId == iLastPoint && usLinkCount > 1) { // Increase the attempts count byteCount++; if(byteCount > 10) break; // Generate a random link id unsigned short usLinkId = usStartLink + (rand() % usLinkCount); // Set the node to the next random link SetLink(usLinkId); } // Check if we need to change the node id if(m_nodeLink.usAreaId != m_iNodeId) { if(m_nodeLink.usAreaId != 65535) { if((iChangeNode = CCallbackManager::OnChangeNode(pPlayer->GetId(), (int)m_nodeLink.usAreaId))) return pPlayer->ChangeNode(m_nodeLink.usAreaId, usLinkId); } else return 0; } else { // Set the next point SetPoint(m_nodeLink.usNodeId); // Get the point position CVector3 vecPosition; GetPosition(&vecPosition); // Set the player velocity pPlayer->SetVelocity(vecVelocity); // Move the player to it pPlayer->GoTo(vecPosition, iType == NODE_TYPE_PED ? MOVE_TYPE_WALK : MOVE_TYPE_DRIVE, true); return m_nodeLink.usNodeId; } } return 0; }
TEST_F(getLinkCountTest, LinkCountOfMultiplyLinkedFile) { createFileForTesting(file); std::string newFile = createHardLink(file); int32_t ret = GetLinkCount(file, &count); ASSERT_EQ(0, ret); EXPECT_EQ(2, count); removeFile(file); removeFile(newFile); }
bool CNPNullPoint::IsLinkedTo (CNPNullPoint *pDest) // IsLinkedTo // // Returns TRUE if the destination is linked to this null point { for (int i = 0; i < GetLinkCount(); i++) if (pDest->m_dwUNID == GetLinkDest(i)->m_dwUNID) return true; return false; }
//adds a temporary AreaEntry to the world map //this entry has two links for each direction, leading to the two areas //we were travelling between when using the supplied link void WorldMap::SetEncounterArea(const ieResRef area, WMPAreaLink *link) { unsigned int i; if (GetArea(area, i)) { return; } //determine the area the link came from unsigned int j, cnt = GetLinkCount(); for (j = 0; j < cnt; ++j) { if (link == area_links[j]) { break; } } i = WhoseLinkAmI(j); if (i == (unsigned int) -1) { Log(ERROR, "WorldMap", "Could not add encounter area"); return; } WMPAreaEntry *ae = GetNewAreaEntry(); ae->SetAreaStatus(WMP_ENTRY_VISIBLE|WMP_ENTRY_ACCESSIBLE|WMP_ENTRY_VISITED, BM_SET); CopyResRef(ae->AreaName, area); CopyResRef(ae->AreaResRef, area); ae->LocCaptionName = -1; ae->LocTooltipName = -1; ae->IconSeq = -1; CopyResRef(ae->LoadScreenResRef, ""); WMPAreaEntry *src = area_entries[i]; WMPAreaEntry *dest = area_entries[link->AreaIndex]; ae->X = src->X + (int) (dest->X - src->X) / 2; ae->Y = src->Y + (int) (dest->Y - src->Y) / 2; //setup the area links WMPAreaLink *ldest = new WMPAreaLink(); memcpy(ldest, link, sizeof(WMPAreaLink)); ldest->DistanceScale /= 2; ldest->EncounterChance = 0; link = GetLink(dest->AreaName, src->AreaName); if (!link) { Log(ERROR, "WorldMap", "Could not find link from %s to %s", dest->AreaName, src->AreaName); delete ae; delete ldest; return; } WMPAreaLink *lsrc = new WMPAreaLink(); memcpy(lsrc, link, sizeof(WMPAreaLink)); lsrc->DistanceScale /= 2; lsrc->EncounterChance = 0; unsigned int idx = area_links.size(); AddAreaLink(ldest); AddAreaLink(lsrc); for (i = 0; i < 4; ++i) { ae->AreaLinksCount[i] = 2; ae->AreaLinksIndex[i] = idx; } encounterArea = area_entries.size(); AddAreaEntry(ae); }
void SetupInstance() { int n = 5; //for( n = 0; n < 100; n++ ) { // Filling out application description: // sType is mandatory vl.applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; // pNext is mandatory vl.applicationInfo.pNext = NULL; // The name of our application vl.applicationInfo.pApplicationName = GetProgramName(); // The name of the engine (e.g: Game engine name) vl.applicationInfo.pEngineName = "SACK Core"; // The version of the engine vl.applicationInfo.engineVersion = 1; // The version of Vulkan we're using for this application vl.applicationInfo.apiVersion = VK_API_VERSION_1_0 | n; // Filling out instance description: // sType is mandatory vl.instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; // pNext is mandatory vl.instanceInfo.pNext = NULL; // flags is mandatory vl.instanceInfo.flags = 0; // The application info structure is then passed through the instance vl.instanceInfo.pApplicationInfo = &vl.applicationInfo; // Don't enable and layer vl.instanceInfo.enabledLayerCount = 0; vl.instanceInfo.ppEnabledLayerNames = NULL; // Don't enable any extensions vl.instanceInfo.enabledExtensionCount = 0; vl.instanceInfo.ppEnabledExtensionNames = NULL; // open an actual output device... { PLIST enabledExtensions = NULL; AddLink( &enabledExtensions, VK_KHR_SURFACE_EXTENSION_NAME ); #if defined(_WIN32) AddLink( &enabledExtensions, VK_KHR_WIN32_SURFACE_EXTENSION_NAME ); #else AddLink( &enabledExtensions, VK_KHR_XCB_SURFACE_EXTENSION_NAME ); #endif vl.instanceInfo.enabledExtensionCount = GetLinkCount( enabledExtensions ); vl.instanceInfo.ppEnabledExtensionNames = (const char*const*)GetLinkAddress( &enabledExtensions, 0 ); } { // Now create the desired instance VkResult result = vkCreateInstance( &vl.instanceInfo, NULL, &vl.instance ); if( result != VK_SUCCESS ) { lprintf( "Failed to create instance: %d", result ); //exit( 0 ); } else lprintf( "Success!" ); } } // To Come Later // ... // ... }