public void ExecuteBoundsChange(ACollider collider, bool IsBounds, bool forceUpdate = false) { Debug.Log("ExecuteBoundsChange: changing..."); unsafe { if (IsBounds) { // Debug.Log("ExecuteBoundsChange: changing bounds..."); if (!Bounds.Update(collider.transform, collider.GetCollider_P(), forceUpdate)) { Debug.LogWarning("ExecuteBoundsChange: No update was performed"); } } else { // Debug.Log("ExecuteBoundsChange: changing cropbounds..."); if (!CropBounds.Update(collider.transform, collider.GetCollider_P(), forceUpdate)) { Debug.LogWarning("ExecuteBoundsChange: No update was performed"); } } } CalculateMinMaxA(); TranslationOffset = float3.zero; RotationOffset = float3.zero; }
public CropSection3D(ACollider bounds, ACollider cropBounds, float3 translationOffset = new float3(), float3 rotationOffset = new float3()) { Bounds = bounds; CropBounds = cropBounds; OriginalTranslation = bounds.transform.pos; OriginalRotation = bounds.transform.rot; TranslationOffset = translationOffset; TranslationOffsetMin = new float3(); TranslationOffsetMax = new float3(); RotationOffset = rotationOffset; RotationOffsetMin = new float3(); RotationOffsetMax = new float3(); CurrentRotation = cropBounds.transform.rot; CurrentTranslation = cropBounds.transform.pos; SubtractionMode = false; SubModeMaxOffset = 0f; SubModeMaxROffset = 0f; CalculateMinMaxA(); ValidateMinMax(); UpdateCropSection(TranslationOffset, RotationOffset); }
/// <summary> /// updates the cropSection's values and returns true if an update occured /// </summary> public bool UpdateCropSection(float3 translationOffset, float3 rotationOffset) { // Debug.Log(TranslationOffset+"::"+translationOffset); // test for new offset bool TranslationChanged = !translationOffset.Equals(TranslationOffset); bool RotationChanged = !rotationOffset.Equals(RotationOffset); // Debug.Log(rotationOffset+",,"+RotationOffset); if (TranslationChanged || RotationChanged) { // Debug.Log(TranslationChanged + "." + RotationChanged); // verify that the change wsas made inside bounds // OffsetExceedsBounds(translationOffset,TranslationOffsetMin,TranslationOffsetMax,out bool3 positiveDirection,out translationOffset); if (SubtractionMode.x || SubtractionMode.y || SubtractionMode.z) { // Debug.Log("Detected Subtraction Mode"); // last changed value takes priority bool3 changed = translationOffset != TranslationOffset; float3 total = SubModeMaxOffset; total = SubtractFromOffsetB(changed, total, ref translationOffset); total = SubtractFromOffsetB(!changed, total, ref translationOffset); // Debug.Log(translationOffset+"::"+TranslationOffset); TranslationOffset = translationOffset; } ACollider tmp = CropBounds; // Debug.Log(OriginalTranslation + "::" + new RigidTransform(OriginalRotation.value + quaternion.Euler(rotationOffset).value, OriginalTranslation + translationOffset).ToString()); RigidTransform trans = new RigidTransform(OriginalRotation, OriginalTranslation); trans.pos += translationOffset; // this is not calculated correctly and will be fixed later // Debug.Log("test old rot = "+RotationOffset+",,"+rotationOffset+",,,,"+ quaternion.EulerXYZ(math.radians(rotationOffset))+"radians: "+math.radians(rotationOffset)+":::"); trans.rot = math.mul(trans.rot, quaternion.EulerXYZ(math.radians(rotationOffset.x), math.radians(rotationOffset.y), math.radians(rotationOffset.z))); // Debug.Log("Offset Match Test: "+RotationOffset+",,"+trans.rot.value+",,"+new Quaternion(trans.rot.value.x, trans.rot.value.y, trans.rot.value.z, trans.rot.value.w).eulerAngles); unsafe { tmp.UpdateAabb(trans); } Debug.Log(CropBounds.AabbToString() + "\n" + CropBounds.properties.height + "\n" + AColliderProperties.GetSize(CropBounds.properties) + "\n" + CropBounds.properties.ToString()); // verify that the CropBounds is within the Bounds if (Bounds.Contains(tmp)) { //update Bounds CropBounds.UpdateAabb(tmp.transform); CurrentTranslation = CropBounds.transform.pos; CurrentRotation = CropBounds.transform.rot; TranslationOffset = translationOffset; RotationOffset = rotationOffset; return(true); } else { // do nothing but you shouldn't get to this if the max was done right. Debug.LogWarning("Detected you somehow exceeded the bounds!"); return(false); } // Debug.Log("Bounds Properties::: " + Bounds.ToString() + "\ntmp Properties::: \n" + tmp.ToString()); // Debug.Log("CropBounds props::: "+CropBounds.ToString()); } return(false); }
private void Awake() { instance = this; }