bool ON_Mesh::DeleteFace( int meshfi ) { // Do NOT add a call Compact() in this function. // Compact() is slow and this function may be called // many times in sequence. // It is the callers responsibility to call Compact() // when it is needed. bool rc = false; if ( meshfi >= 0 && meshfi < m_F.Count() ) { if ( m_top.m_topf.Count() > 0 ) { DestroyTopology(); } DestroyPartition(); DestroyTree(); if ( m_FN.Count() == m_F.Count() ) { m_FN.Remove(meshfi); } m_F.Remove(meshfi); // 6 Mar 2010 S. Baer // Invalidate the cached IsClosed flag. This forces the mesh to // recompute IsClosed the next time it is called SetClosed(-1); rc = true; } return rc; }
varargs mixed eventOpen(object who, object tool){ if( SetClosed(0) ){ return 0; } send_messages("open", "$agent_name $agent_verb $target_name.", who, this_object(), environment(who)); return 1; }
mixed eventClose(object who){ if( !SetClosed(1) ){ return 0; } send_messages("close", "$agent_name $agent_verb $target_name.", who, this_object(), environment(who)); return 1; }
void RotatingDoor::Closing() { LTBOOL bDoneInX = LTFALSE; LTBOOL bDoneInY = LTFALSE; LTBOOL bDoneInZ = LTFALSE; LTVector vOldAngles(m_fPitch, m_fYaw, m_fRoll); // Calculate new pitch, yaw, and roll... bDoneInX = CalcAngle(m_fPitch, m_vOpenAngles.x, m_vClosedAngles.x, -m_vOpenDir.x, m_fClosingSpeed); bDoneInY = CalcAngle(m_fYaw, m_vOpenAngles.y, m_vClosedAngles.y, -m_vOpenDir.y, m_fClosingSpeed); bDoneInZ = CalcAngle(m_fRoll, m_vOpenAngles.z, m_vClosedAngles.z, -m_vOpenDir.z, m_fClosingSpeed); LTVector vPos; LTRotation rRot; // Calcuate the new pos/rot for the door (testing object collisions)... // If we collide with an object in the new position, don't move // the door (if force move isn't set)... if (!CalcPosAndRot(vPos, rRot, LTTRUE) && !(m_dwStateFlags & DF_FORCEMOVE)) { // Restore our angles... m_fPitch = vOldAngles.x; m_fYaw = vOldAngles.y; m_fRoll = vOldAngles.z; // Since we hit something, try to open... //SetOpening(); // Doesn't work... return; } // Set the object's new rotation and position... g_pLTServer->RotateObject(m_hObject, &rRot); g_pLTServer->MoveObject(m_hObject, &vPos); // Update the light animation.... float fPercent = GetRotatingLightAnimPercent(); ReallySetLightAnimPos(fPercent); if (bDoneInX && bDoneInY && bDoneInZ) { SetClosed(); } }
bool VectorPath::SetToPropertyObject(const PropertyObject* object) { AutoNotificationSuspender _(this); IconObject::SetToPropertyObject(object); SetClosed(object->Value(PROPERTY_CLOSED, fClosed)); IconProperty* pathProperty = dynamic_cast<IconProperty*>( object->FindProperty(PROPERTY_PATH)); if (pathProperty && pathProperty->Message()) { VectorPath archivedPath(pathProperty->Message()); *this = archivedPath; } return HasPendingNotifications(); }
static void create() { door::create(); SetId("north", "door"); SetShort("north", "a door made from fine oak"); SetLong("north", "It is a magnificent door marking the entrance to " "the fighter class hall."); SetLockable("north", 1); SetKeys("north", "special_key_id"); SetId("south", "door"); SetShort("south", "a door made from fine oak"); SetLong("south", "It is a magnificent door leading out to the recruitment " "area."); SetLockable("south", 1); SetKeys("south", "special_key_id"); SetClosed(1); SetLocked(0); }
PAPoint CAStarBase::CalcNextPoint(PAPoint ptCalc, char* pDateArr) { if (ptCalc == NULL) ptCalc = m_pStartPoint; int x = ptCalc->x; int y = ptCalc->y; int shop_point_num = 0; while (m_pShopPoint[shop_point_num]) { dx[shop_point_num] = m_pShopPoint[shop_point_num]->x; dy[shop_point_num] = m_pShopPoint[shop_point_num]->y; shop_point_num++; } Stshop_point_num = shop_point_num; dx[Stshop_point_num] = m_pEndPoint->x; dy[Stshop_point_num] = m_pEndPoint->y; int xmin = x, ymin = y; int vmin = 0; // 最优步骤的坐标和值 static int i = 0; if ((x == dx[i] && abs(y - dy[i]) == 1) || (y == dy[i] && abs(x - dx[i]) == 1)) //是否在终点的周围 { m_pAPointArr[dx[i] + m_nAPointArrWidth*dy[i]].g = m_pAPointArr[x + m_nAPointArrWidth*y].g + 1; vmin = 0; printf("\r\n\n"); if (FindPointPath(dx[i], dy[i], m_pAPointArr[x + m_nAPointArrWidth*y].g) == m_pStartPoint) PrintCharArr(pDateArr); if ((x == dx[Stshop_point_num] && abs(y - dy[Stshop_point_num]) == 1) || (y == dy[Stshop_point_num] && abs(x - dx[Stshop_point_num]) == 1)) { i = 0; //PrintCharArr(pDateArr); return m_pEndPoint; } vmin = 0; //PrintCharArr(pDateArr); m_pStartPoint = m_pAPointArr + dy[i] * m_nAPointArrWidth + dx[i]; i++; return CalcNextPoint(m_pStartPoint, pDateArr); } // 上 if ((m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].type == APT_UNKNOWN) && y > 0) { m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].g = m_pAPointArr[x + m_nAPointArrWidth*y].g + 1; m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].h = 10 * (abs(x - dx[i]) + abs(y - 1 - dy[i])); m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].f = m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].g + m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].h; m_pAPointArr[x + m_nAPointArrWidth*(y - 1)].type = APT_OPENED; if (vmin == 0) { xmin = x; ymin = y - 1; vmin = m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].h; } else{ if (vmin > m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].h) { xmin = x; ymin = y - 1; vmin = m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y - 1)].h; } } } // 下 if ((m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].type == APT_UNKNOWN) && y < m_nAPointArrHeight) { m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].g = m_pAPointArr[x + m_nAPointArrWidth*y].g + 1; m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].h = 10 * (abs(x - dx[i]) + abs(y + 1 - dy[i])); m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].f = m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].g + m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].h; m_pAPointArr[x + m_nAPointArrWidth*(y + 1)].type = APT_OPENED; if (vmin == 0) { xmin = x; ymin = y + 1; vmin = m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].h; } else{ if (vmin > m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].h) { xmin = x; ymin = y + 1; vmin = m_pAPointArr[(x + 0) + m_nAPointArrWidth*(y + 1)].h; } } } // 左 if ((m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].type == APT_UNKNOWN) && x > 0) { m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].g = m_pAPointArr[x + m_nAPointArrWidth*y].g + 1; m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].h = 10 * (abs(x - 1 - dx[i]) + abs(y - dy[i])); m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].f = m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].g + m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].h; m_pAPointArr[(x - 1) + m_nAPointArrWidth* y].type = APT_OPENED; if (vmin == 0) { xmin = x - 1; ymin = y; vmin = m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].h; } else{ if (vmin > m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].h) { xmin = x - 1; ymin = y; vmin = m_pAPointArr[(x - 1) + m_nAPointArrWidth*y].h; } } } // 右 if ((m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].type == APT_UNKNOWN) && x < m_nAPointArrWidth) { m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].g = m_pAPointArr[x + m_nAPointArrWidth*y].g + 1; m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].h = 10 * (abs(x + 1 - dx[i]) + abs(y - dy[i])); m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].f = m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].g + m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].h; m_pAPointArr[(x + 1) + m_nAPointArrWidth* y].type = APT_OPENED; if (vmin == 0) { xmin = x + 1; ymin = y; vmin = m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].h; } else{ if (vmin > m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].h) { xmin = x + 1; ymin = y; vmin = m_pAPointArr[(x + 1) + m_nAPointArrWidth*y].h; } } } int Vim_Campare_x, Vim_Campare_y; if (vmin) { if (vmin > m_pAPointArr[x + m_nAPointArrWidth*y].h) { for (int for_x = 0; for_x < m_nAPointArrWidth; for_x++) { for (int for_y = 0; for_y < m_nAPointArrHeight; for_y++) { if (m_pAPointArr[for_x + m_nAPointArrWidth*for_y].type == APT_OPENED) { if (m_pAPointArr[for_x + m_nAPointArrWidth*for_y].h < vmin) { SetCurrent(for_x, for_y); SetClosed(for_x, for_y); return CalcNextPoint(m_pCurPoint, pDateArr); } } } } } SetCurrent(xmin, ymin); SetClosed(xmin, ymin); return CalcNextPoint(m_pCurPoint, pDateArr); } else{ int Vim_Campare_h=500; for (int for_x = 0; for_x < m_nAPointArrWidth; for_x++) { for (int for_y = 0; for_y < m_nAPointArrHeight; for_y++) { if (m_pAPointArr[for_x + m_nAPointArrWidth*for_y].type == APT_OPENED) { if (m_pAPointArr[for_x + m_nAPointArrWidth*for_y].h < Vim_Campare_h) { Vim_Campare_h = m_pAPointArr[for_x + m_nAPointArrWidth*for_y].h; Vim_Campare_x = m_pAPointArr[for_x + m_nAPointArrWidth*for_y].x; Vim_Campare_y = m_pAPointArr[for_x + m_nAPointArrWidth*for_y].y; } } } } SetCurrent(Vim_Campare_x, Vim_Campare_y); SetClosed(Vim_Campare_x, Vim_Campare_y); return CalcNextPoint(m_pCurPoint, pDateArr); } }