Quote:
Originally Posted by FroGeX
it did exactly what you wrote
|
no, it didn't
childrens have same vecmins vecmaxs when parents are moving, only the origin is not the same (tested with trigger_hurt, physboxes are just fine, their mins and maxs are updated every frame when parent is moving).
Example here:
https://imgur.com/a/yNB3WlR
The green box which seems its not moving it's a trigger_hurt parented to the moving entity.
I wrote this code:
PHP Code:
void GetAngularMinsMaxs(int entity, Classname entityType, float vecMins[3], float vecMaxs[3], float vecOrigin[3])
{
RotationType rotationType;
float vecRotation[3];
GetEntPropVector(entity, Prop_Data, "m_angAbsRotation", vecRotation);
float newMins[3];
float newMaxs[3];
for (int i = 0; i < 3; i++)
{
newMins[i] = vecMins[i];
newMaxs[i] = vecMaxs[i];
}
int spawnFlags = GetEntProp(entity, Prop_Data, "m_spawnflags");
if (entityType == Func_Rotating)
{
if (view_as<bool>(spawnFlags & SF_BRUSH_ROTATE_X_AXIS))
{
rotationType = RotationType_Roll;
}
else if (view_as<bool>(spawnFlags & SF_BRUSH_ROTATE_Y_AXIS))
{
rotationType = RotationType_Pitch;
}
}
else // func_door_rotating
{
if (view_as<bool>(spawnFlags & SF_DOOR_ROTATE_ROLL))
{
rotationType = RotationType_Roll;
}
else if (view_as<bool>(spawnFlags & SF_DOOR_ROTATE_PITCH))
{
rotationType = RotationType_Pitch;
}
}
switch (rotationType)
{
case RotationType_Yaw:
{
float angle = vecRotation[1] * 3.14 / 180.0;
newMins[0] = Cosine(angle) * vecMins[0] - Sine(angle) * vecMins[1];
newMins[1] = Sine(angle) * vecMins[0] + Cosine(angle) * vecMins[1];
newMaxs[0] = Cosine(angle) * vecMaxs[0] - Sine(angle) * vecMaxs[1];
newMaxs[1] = Sine(angle) * vecMaxs[0] + Cosine(angle) * vecMaxs[1];
}
case RotationType_Roll:
{
float angle = vecRotation[2] * 3.14 / 180.0;
newMins[1] = Cosine(angle) * vecMins[1] - Sine(angle) * vecMins[2];
newMins[2] = Sine(angle) * vecMins[1] + Cosine(angle) * vecMins[2];
newMaxs[1] = Cosine(angle) * vecMaxs[1] - Sine(angle) * vecMaxs[2];
newMaxs[2] = Sine(angle) * vecMaxs[1] + Cosine(angle) * vecMaxs[2];
}
case RotationType_Pitch:
{
float angle = vecRotation[0] * 3.14 / 180.0;
newMins[0] = Cosine(angle) * vecMins[0] - Sine(angle) * vecMins[2];
newMins[2] = Sine(angle) * vecMins[0] + Cosine(angle) * vecMins[2];
newMaxs[0] = Cosine(angle) * vecMaxs[0] - Sine(angle) * vecMaxs[2];
newMaxs[2] = Sine(angle) * vecMaxs[0] + Cosine(angle) * vecMaxs[2];
}
}
for (int i = 0; i < 3; i++)
{
vecMins[i] = newMins[i] + vecOrigin[i];
vecMaxs[i] = newMaxs[i] + vecOrigin[i];
}
GetMiddleOfABox(vecMins, vecMaxs, vecOrigin);
}
void GetMiddleOfABox(float vecMins[3], float vecMaxs[3], float vecOrigin[3])
{
float middle[3];
MakeVectorFromPoints(vecMins, vecMaxs, middle);
for (int i = 0; i < 3; i++)
{
middle[i] /= 2.0;
}
AddVectors(vecMins, middle, vecOrigin);
SubtractVectors(vecMins, vecOrigin, vecMins);
SubtractVectors(vecMaxs, vecOrigin, vecMaxs);
for (int i = 0; i < 3; i++)
{
if (vecMins[i] > 0.0)
{
vecMins[i] *= -1.0;
}
if (vecMaxs[i] < 0.0)
{
vecMaxs[i] *= -1.0;
}
}
}
For some entities, everything is fine, but for others, something strange happens.
https://imgur.com/a/2JZLYSo
A square becomes a rectangle and a square again (the rectangle will have a side very small, close to 1 - 10 units).
The green lines represents the mins and maxs calculated with this function. For rectangles everything seems fine, but for squares - like the door_rotating from picture - this strange bug occurs.
__________________