예제 #1
0
파일: c3_act1.c 프로젝트: BSzili/refkeen
void T_BatPast (objtype *ob)
{
	id0_long_t move;
	//id0_long_t deltax,deltay,size;

	move = ob->speed*tics;

	do
	{
		if (move < ob->distance)
		{
			MoveObj (ob,move);
			break;
		}
		actorat[ob->tilex][ob->tiley] = 0;	// pick up marker from goal

		ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
		ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
		move -= ob->distance;

		BatRunThink (ob);

		actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob);	// set down a new goal marker
		//actorat[ob->tilex][ob->tiley] = ob;	// set down a new goal marker
	} while (0);	//(move)
	CalcBounds (ob);
}
예제 #2
0
//-----------------------------------------------------------------------------
// Purpose: Builds the spline points between this keyframe and the previous
//			keyframe.
// Input  : pPrev - 
//-----------------------------------------------------------------------------
void CMapKeyFrame::BuildPathSegment( CMapKeyFrame *pPrev )
{
	RecalculateTimeFromSpeed();

	CMapAnimator *pAnim = GetAnimator();

	Quaternion qAngles;
	for ( int i = 0; i < MAX_LINE_POINTS; i++ )
	{
		if (pAnim != NULL)
		{
			CMapAnimator::GetAnimationAtTime( this, pPrev, MoveTime() * ( float )( i + 1 ) / (float)MAX_LINE_POINTS, m_LinePoints[i], qAngles, pAnim->m_iPositionInterpolator, pAnim->m_iRotationInterpolator );
		}
		else
		{
			// FIXME: If we aren't connected to an animator yet, just draw straight lines. This code is never hit, because
			//		 BuildPathSegment is only called from CMapAnimator. To make matters worse, we can only reliably find
			//		 pPrev through an animator.
			CMapAnimator::GetAnimationAtTime( this, pPrev, MoveTime() * (float)( i + 1) / (float)MAX_LINE_POINTS, m_LinePoints[i], qAngles, 0, 0 );
		}
	}

	// HACK: we shouldn't need to do this. CalcBounds alone should work (but it doesn't because of where we
	// call RebuildPath from). Make this work more like other objects.
	if ( m_pParent )
	{
		GetParent()->CalcBounds( true );
	}
	else
	{
		CalcBounds();
	}

	m_bRebuildPath = false;
}
예제 #3
0
//-----------------------------------------------------------------------------
// Purpose: Special implementation of UpdateChild for the world object. This
//			notifies the document that an object's bounding box has changed.
// Input  : pChild - 
//-----------------------------------------------------------------------------
void CMapWorld::UpdateChild(CMapClass *pChild)
{
	if ( CMapClass::s_bLoadingVMF )
		return;
	
	// Recalculate the bounds of this child's branch.
	pChild->CalcBounds(TRUE);

	// Recalculate own bounds
	CalcBounds( FALSE );

	//
	// Relink the child in the culling tree.
	//
	if (m_pCullTree != NULL)
	{
		m_pCullTree->UpdateCullTreeObjectRecurse(pChild);
	}

	//
	// Notify the document that an object in the world has changed.
	//
	if (!IsTemporary()) // HACK: check to avoid prefab objects ending up in the doc's update list
	{
		CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
		if (pDoc != NULL)
		{
			pDoc->UpdateObject(pChild);
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : szKey - 
//			szValue - 
//-----------------------------------------------------------------------------
void CMapPointHandle::OnParentKeyChanged(const char *szKey, const char *szValue)
{
	if (stricmp(szKey, m_szKeyName) == 0)
	{
		sscanf(szValue, "%f %f %f", &m_Origin.x, &m_Origin.y, &m_Origin.z);
		CalcBounds();
	}
}
예제 #5
0
Vector3 RayCast::Move()
{
	//CalcIncrement(val);
	RayPos.x += StoredDirVec.x * Speed;
	RayPos.y += StoredDirVec.y * Speed;
	RayPos.z += StoredDirVec.z * Speed;
	CalcBounds();
	return RayPos;
}
예제 #6
0
파일: c4_state.c 프로젝트: BSzili/refkeen
id0_boolean_t Chase (objtype *ob, id0_boolean_t diagonal)
{
	id0_long_t move;
	id0_long_t deltax,deltay,size;

	ob->flags &= ~of_damagedone;

	move = ob->speed*tics;
	size = (id0_long_t)ob->size + player->size + move + SIZE_TEST;

	while (move)
	{
		deltax = ob->x - player->x;
		deltay = ob->y - player->y;

		if (deltax <= size && deltax >= -size
		&& deltay <= size && deltay >= -size)
		{
			CalcBounds (ob);
			return true;
		}

		if (move < ob->distance)
		{
			MoveObj (ob,move);
			break;
		}
		actorat[ob->tilex][ob->tiley] = 0;	// pick up marker from goal
		if (ob->dir == nodir)
			ob->dir = north;

		ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
		ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
		move -= ob->distance;

		ChaseThink (ob,diagonal);
		if (!ob->distance)
			break;			// no possible move
		actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob);	// set down a new goal marker
		//actorat[ob->tilex][ob->tiley] = ob;	// set down a new goal marker
	}
	CalcBounds (ob);
	return false;
}
예제 #7
0
//-----------------------------------------------------------------------------
// Purpose: Call this function after changing this object via transformation,
//			etc. Notifies dependents and updates the parent with this object's
//			new size.
//-----------------------------------------------------------------------------
void CMapClass::PostUpdate(Notify_Dependent_t eNotifyType)
{
	CalcBounds();

	NotifyDependents(eNotifyType);

	if (Parent != NULL)
	{
		Parent->UpdateChild(this);
	}
}
예제 #8
0
파일: c3_act1.c 프로젝트: BSzili/refkeen
void T_Bat (objtype *ob)
{
	id0_long_t move;
	id0_long_t deltax,deltay,size;

	move = ob->speed*tics;
	size = (id0_long_t)ob->size + player->size + move;


	do
	{
		deltax = ob->x - player->x;
		deltay = ob->y - player->y;

		if (deltax <= size && deltax >= -size
		&& deltay <= size && deltay >= -size && !ob->temp1)
		{
			TakeDamage (4);
			ob->temp1 = 2;
		}

		if (move < ob->distance)
		{
			MoveObj (ob,move);
			break;
		}

		actorat[ob->tilex][ob->tiley] = 0;	// pick up marker from goal
		if (ob->dir == nodir)
			ob->dir = north;

		ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
		ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
		move -= ob->distance;

		if (ob->temp1)
		{
			Walk (ob);				// go straight
			if (!--ob->temp1)
			{
				ob->state = &s_batpast;
				ob->ticcount = ob->state->tictime;
			}
		}
		else
			BatChaseThink (ob);		// head towards player

		actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); // set down a new goal marker
		//actorat[ob->tilex][ob->tiley] = ob;	// set down a new goal marker
	} while (0);	// just once
	CalcBounds (ob);
}
bool UDebugSkelMeshComponent::CheckIfBoundsAreCorrrect()
{
	if (GetPhysicsAsset())
	{
		bool bWasUsingInGameBounds = IsUsingInGameBounds();
		FTransform TempTransform = FTransform::Identity;
		UseInGameBounds(true);
		FBoxSphereBounds InGameBounds = CalcBounds(TempTransform);
		UseInGameBounds(false);
		FBoxSphereBounds PreviewBounds = CalcBounds(TempTransform);
		UseInGameBounds(bWasUsingInGameBounds);
		// calculate again to have bounds as requested
		CalcBounds(TempTransform);
		// if in-game bounds are of almost same size as preview bounds or bigger, it seems to be fine
		if (! InGameBounds.GetSphere().IsInside(PreviewBounds.GetSphere(), PreviewBounds.GetSphere().W * 0.1f) && // for spheres: A.IsInside(B) checks if A is inside of B
			! PreviewBounds.GetBox().IsInside(InGameBounds.GetBox().ExpandBy(PreviewBounds.GetSphere().W * 0.1f))) // for boxes: A.IsInside(B) checks if B is inside of A
		{
			return true;
		}
	}
	return false;
}
예제 #10
0
파일: c3_state.c 프로젝트: BSzili/refkeen
void SpawnNewObjFrac (id0_long_t x, id0_long_t y, statetype *state, id0_unsigned_t size)
{
	GetNewObj (false);
	newobj->size = size;
	newobj->state = state;
	newobj->ticcount = BE_Cross_Brandom (state->tictime)+1;
	newobj->active = yes/*true*/;

	newobj->x = x;
	newobj->y = y;
	newobj->tilex = x>>TILESHIFT;
	newobj->tiley = y>>TILESHIFT;
	CalcBounds(newobj);
	newobj->distance = 100;
	newobj->dir = nodir;
}
예제 #11
0
파일: c4_state.c 프로젝트: BSzili/refkeen
void Internal_SpawnNewObjFrac (id0_long_t x, id0_long_t y, statetype *state, id0_unsigned_t size,id0_boolean_t UseDummy)
{
	GetNewObj(UseDummy);
	newobj->size = size;
	newobj->state = state;
	newobj->ticcount = BE_Cross_Brandom (state->tictime)+1;
	newobj->active = noalways;

	newobj->x = x;
	newobj->y = y;
	newobj->tilex = x>>TILESHIFT;
	newobj->tiley = y>>TILESHIFT;
	CalcBounds(newobj);
	newobj->distance = 100;
	newobj->dir = nodir;
}
예제 #12
0
파일: c3_state.c 프로젝트: BSzili/refkeen
void SpawnNewObj (id0_unsigned_t x, id0_unsigned_t y, statetype *state, id0_unsigned_t size)
{
	GetNewObj (false);
	newobj->size = size;
	newobj->state = state;
	newobj->ticcount = BE_Cross_Brandom (state->tictime)+1;

	newobj->tilex = x;
	newobj->tiley = y;
	newobj->x = ((id0_long_t)x<<TILESHIFT)+TILEGLOBAL/2;
	newobj->y = ((id0_long_t)y<<TILESHIFT)+TILEGLOBAL/2;
	CalcBounds(newobj);
	newobj->dir = nodir;

	actorat[newobj->tilex][newobj->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(newobj);
	//actorat[newobj->tilex][newobj->tiley] = newobj;
}
예제 #13
0
//-----------------------------------------------------------------------------
// Purpose: Calculates the midpoint of the line and sets our origin there.
//-----------------------------------------------------------------------------
void CMapLine::BuildLine(void)
{
	if ((m_pStartEntity != NULL) && (m_pEndEntity != NULL))
	{
		//
		// Set our origin to our midpoint. This moves our selection handle box to the
		// midpoint.
		//
		Vector Start;
		Vector End;

		m_pStartEntity->GetOrigin(Start);
		m_pEndEntity->GetOrigin(End);

		SetOrigin((Start + End) / 2);
	}

	CalcBounds();
}
예제 #14
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pszValue - 
//			pWorld - The world object that we are contained in.
//-----------------------------------------------------------------------------
void CMapSideList::BuildFaceListForValue(char const *pszValue, CMapWorld *pWorld)
{
	CMapFaceList NewFaces;
	pWorld->FaceID_StringToFaceLists(&NewFaces, NULL, pszValue);

	//
	// Detach from the faces that are not in the new list. Go
	// in reverse order since we are removing items as we go.
	//
	if (m_Faces.Count() > 0)
	{
		for (int i = m_Faces.Count() - 1; i >= 0; i--)
		{
			CMapFace *pFace = m_Faces.Element(i);
			ASSERT(pFace != NULL);
			if ((pFace != NULL) && (NewFaces.Find(pFace) == -1))
			{
				CMapSolid *pSolid = (CMapSolid *)pFace->GetParent();
				UpdateDependency(pSolid, NULL);
				m_Faces.FastRemove(i);
			}
		}
	}

	//
	// Attach to the faces that are not in the old list.
	//
	for (int i = 0; i < NewFaces.Count(); i++)
	{
		CMapFace *pFace = NewFaces.Element(i);
		ASSERT(pFace != NULL);

		if ((pFace != NULL) && (m_Faces.Find(pFace) == -1))
		{
			CMapSolid *pSolid = (CMapSolid *)pFace->GetParent();
			UpdateDependency(NULL, pSolid);
			m_Faces.AddToTail(pFace);
		}
	}

	CalcBounds();
}
예제 #15
0
파일: c4_state.c 프로젝트: BSzili/refkeen
/*
===================
=
= Internal_SpawnNewObj
=
===================
*/
void Internal_SpawnNewObj (id0_unsigned_t x, id0_unsigned_t y, statetype *state, id0_unsigned_t size,id0_boolean_t UseDummy)
{
	extern objtype dummyobj;

	GetNewObj(UseDummy);
	newobj->size = size;
	newobj->state = state;
	newobj->ticcount = BE_Cross_Brandom (state->tictime)+1;

	newobj->tilex = x;
	newobj->tiley = y;
	newobj->x = ((id0_long_t)x<<TILESHIFT)+TILEGLOBAL/2;
	newobj->y = ((id0_long_t)y<<TILESHIFT)+TILEGLOBAL/2;
	CalcBounds(newobj);
	newobj->dir = nodir;
	newobj->active = noalways;

	if (newobj != &dummyobj)
		actorat[newobj->tilex][newobj->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(newobj);
		//actorat[newobj->tilex][newobj->tiley] = newobj;
}
void USkeletalMeshComponent::UpdateBounds()
{
#if WITH_EDITOR
	FBoxSphereBounds OriginalBounds = Bounds; // Save old bounds
#endif

	// if use parent bound if attach parent exists, and the flag is set
	// since parents tick first before child, this should work correctly
	if ( bUseAttachParentBound && AttachParent != NULL )
	{
		Bounds = AttachParent->Bounds;
	}
	else
	{
		// fixme laurent - extend concept of LocalBounds to all SceneComponent
		// as rendered calls CalcBounds*() directly in FScene::UpdatePrimitiveTransform, which is pretty expensive for SkelMeshes.
		// No need to calculated that again, just use cached local bounds.
		if( bCachedLocalBoundsUpToDate )
		{
			Bounds = CachedLocalBounds.TransformBy(ComponentToWorld);
		}
		else
		{
			// Calculate new bounds
			Bounds = CalcBounds(ComponentToWorld);

			bCachedLocalBoundsUpToDate = true;
			CachedLocalBounds = Bounds.TransformBy(ComponentToWorld.InverseSafe());
		}
	}

#if WITH_EDITOR
	// If bounds have changed (in editor), trigger data rebuild
	if ( IsRegistered() && (World != NULL) && !GetWorld()->IsGameWorld() && 
		(OriginalBounds.Origin.Equals(Bounds.Origin) == false || OriginalBounds.BoxExtent.Equals(Bounds.BoxExtent) == false) )
	{
		GEngine->TriggerStreamingDataRebuild();
	}
#endif
}
예제 #17
0
파일: c3_act1.c 프로젝트: BSzili/refkeen
void T_Mshot (objtype *ob)
{
	objtype	*check;
	id0_long_t	xmove,ymove/*,speed*/;

	xmove = ymove = 0;

	switch (ob->dir)
	{
	case north:
		ymove = -ob->speed*tics;
		break;
	case east:
		xmove = ob->speed*tics;
		break;
	case south:
		ymove = ob->speed*tics;
		break;
	case west:
		xmove = -ob->speed*tics;
		break;
	}

	ob->x+=xmove;
	ob->y+=ymove;

	CalcBounds (ob);

	ob->tilex = ob->x>>TILESHIFT;
	ob->tiley = ob->y>>TILESHIFT;

	if (tilemap[ob->tilex][ob->tiley])
	{
		SD_PlaySound (SHOOTWALLSND);
		ob->state = NULL;
		return;
	}

//
// check final position for monsters hit
//
	if ( ob->xl <= player->xh
	&& ob->xh >= player->xl
	&& ob->yl <= player->yh
	&& ob->yh >= player->yl)
	{
		TakeDamage (MSHOTDAMAGE*2);
		ob->state = NULL;
		return;
	}

	for (check = player->next; check; check=check->next)
		if (ob->shootable && ob->obclass != mageobj
		&& ob->xl <= check->xh
		&& ob->xh >= check->xl
		&& ob->yl <= check->yh
		&& ob->yh >= check->yl)
		{
			ShootActor (check,MSHOTDAMAGE);
			ob->state = NULL;
			return;
		}
}
예제 #18
0
파일: c3_act1.c 프로젝트: BSzili/refkeen
void T_Bounce (objtype *ob)
{
	id0_long_t move;
	id0_long_t deltax,deltay,size;

	move = SPDBOUNCE*tics;
	size = (id0_long_t)ob->size + player->size + move;

	while (move)
	{
		deltax = ob->x - player->x;
		deltay = ob->y - player->y;

		if (deltax <= size && deltax >= -size
		&& deltay <= size && deltay >= -size && !ob->temp2)
		{
			ob->temp2 = 1;
			TakeDamage (DMGBOUNCE);
		}

		if (move < ob->distance)
		{
			MoveObj (ob,move);
			break;
		}
		actorat[ob->tilex][ob->tiley] = 0;	// pick up marker from goal

		ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
		ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
		move -= ob->distance;

		//
		// bounce if hit wall
		//
		switch (ob->dir)
		{
		case north:
			if (tilemap[ob->tilex][--ob->tiley])
			{
				ob->dir = south;
				ob->tiley+=2;
				ob->temp2 = 0;
			}
			break;
		case east:
			if (tilemap[++ob->tilex][ob->tiley])
			{
				ob->dir = west;
				ob->tilex-=2;
				ob->temp2 = 0;
			}
			break;
		case south:
			if (tilemap[ob->tilex][++ob->tiley])
			{
				ob->dir = north;
				ob->tiley-=2;
				ob->temp2 = 0;
			}
			break;
		case west:
			if (tilemap[--ob->tilex][ob->tiley])
			{
				ob->dir = east;
				ob->tilex+=2;
				ob->temp2 = 0;
			}
			break;
		}

		ob->distance = TILEGLOBAL;

		actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob);	// set down a new goal marker
		//actorat[ob->tilex][ob->tiley] = ob;	// set down a new goal marker
	}
	CalcBounds (ob);
}
예제 #19
0
//-----------------------------------------------------------------------------
// Purpose: Our child's bounding box has changed - recalculate our bounding box.
// Input  : pChild - The child whose bounding box changed.
//-----------------------------------------------------------------------------
void CMapClass::UpdateChild(CMapClass *pChild)
{
	CalcBounds(FALSE);
}
FVector UTextRenderComponent::GetTextWorldSize() const
{
	FBoxSphereBounds Bounds = CalcBounds(ComponentToWorld);
	return Bounds.GetBox().GetSize();
}
FVector UTextRenderComponent::GetTextLocalSize() const
{
	FBoxSphereBounds Bounds = CalcBounds(FTransform::Identity);
	return Bounds.GetBox().GetSize();
}
예제 #22
0
파일: c6_act2.c 프로젝트: BSzili/refkeen
/*
====================
=
= T_RunningEye
=
====================
*/
void T_RunningEye(objtype *ob)
{
	id0_int_t /*x, y, */dir_num, switch_num;
	fixed tempx,tempy;
	id0_unsigned_t temp_tilex,temp_tiley;

	dir_num = *(mapsegs[2]+farmapylookup[ob->tiley]+ob->tilex);
	dir_num = dir_num>>8;

	if (!dir_num)
		dir_num = ob->temp2;

	if (dir_num == 5)
	{
		if (ob->temp1)
		{
			ob->temp1--;
		}
		else
		{
			ob->temp1 = 2;
			actorat[ob->tilex][ob->tiley] = 0;
			switch (ob->temp2)
			{
				case 1:
					ob->tiley = ob->tiley-1;
					ob->y = ((id0_long_t)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2;
				break;

				case 2:
					ob->tilex = ob->tilex+1;
					ob->x = ((id0_long_t)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2;
				break;

				case 3:
					ob->tiley = ob->tiley+1;
					ob->y = ((id0_long_t)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2;
				break;

				case 0:
				case 4:
					ob->tilex = ob->tilex-1;
					ob->x = ((id0_long_t)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2;
				break;
			}
			CalcBounds (ob);
			ChaseThink(ob,false);
			actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob);
			//actorat[ob->tilex][ob->tiley] = ob;
			return;
		}
	}

	tempx = player->x;
	tempy = player->y;
	temp_tilex = player->tilex;
	temp_tiley = player->tiley;

	if (dir_num == 5)
		switch_num = ob->temp2;
	else
		switch_num = dir_num;

	switch (switch_num)
	{
		case 1:
			player->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
			player->y = ((id0_long_t)(ob->tiley-2)<<TILESHIFT)+TILEGLOBAL/2;
			player->tilex = ob->tilex;
			player->tiley = ob->tiley-2;
		break;

		case 2:
			player->x = ((id0_long_t)(ob->tilex+2)<<TILESHIFT)+TILEGLOBAL/2;
			player->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
			player->tilex = ob->tilex+2;
			player->tiley = ob->tiley;
		break;

		case 3:
			player->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
			player->y = ((id0_long_t)(ob->tiley+2)<<TILESHIFT)+TILEGLOBAL/2;
			player->tilex = ob->tilex;
			player->tiley = ob->tiley+2;
		break;

		case 0:
		case 4:
			player->x = ((id0_long_t)(ob->tilex-2)<<TILESHIFT)+TILEGLOBAL/2;
			player->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
			player->tilex = ob->tilex-2;
			player->tiley = ob->tiley;
		break;
	}

	Chase(ob, false);

	player->x = tempx;
	player->y = tempy;
	player->tilex = temp_tilex;
	player->tiley = temp_tiley;

	if (dir_num != 5)
		ob->temp2 = dir_num;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : vecOrigin - 
//-----------------------------------------------------------------------------
void CMapPointHandle::UpdateOrigin(const Vector &vecOrigin)
{
	m_Origin = vecOrigin;
	CalcBounds();
	UpdateParentKey();
}