// ============================ Functions ============================ void Awake() { // 碰撞 权重计算等 过滤器 _fluencePointFilter = GetComponent <ICamFluencePointsFilter>(); // 在实现ICamFluencePointsFilter接口的类中 创建一个过滤意图 _defCamFilterIntent = _fluencePointFilter.createFilterIntent(); }
public bool filter(CamFilterIntent camFilterIntent, out CamFilterResultInfo info) { this._camFilterIntent = camFilterIntent; List <CamInfluenceTriggerPoint> tempLst = createInfluenceQuery(); // 过滤碰撞的 collider 存放入 _camInfiuencePointLst 中 bool hasHit = tempLst.Count > 0; if (tempLst.Count == 2) { int a = 1; } if (hasHit) { Vector3[] positions = tempLst.Select <CamInfluenceTriggerPoint, Vector3>(tp => tp.getCamRigPosition()).ToArray(); Vector3[] facings = tempLst.Select <CamInfluenceTriggerPoint, Vector3>(tp => tp.getCamRigfacing()).ToArray(); Vector3[] ups = tempLst.Select <CamInfluenceTriggerPoint, Vector3>(tp => tp.getCamRigUp()).ToArray(); float[][] weights = tempLst.Select <CamInfluenceTriggerPoint, float[]>(tp => tp.getPositionAndQuaternionInfluenceWeight(camFilterIntent.followTargetGhost)).ToArray(); Vector3 mixedPositionVec3 = Vector3.zero; Vector3 mixedUpVec3 = Vector3.zero; Vector3 mixedForwardVec3 = Vector3.zero; float posWeightSum = 0f; float qWeightSum = 0f; for (int i = 0; i < weights.Length; i++) { float posW = weights[i][0]; float qW = weights[i][1]; posWeightSum += posW; qWeightSum += qW; mixedPositionVec3 += positions[i] * posW; mixedForwardVec3 += facings[i] * qW; mixedUpVec3 += ups[i] * qW; } _resultInfo.resultMixedPosition = mixedPositionVec3 / posWeightSum; _resultInfo.resultMixedForward = mixedForwardVec3 / qWeightSum; _resultInfo.resultMixedUp = mixedUpVec3 / qWeightSum; _resultInfo.hitTriggerPointLst = tempLst; _debugTriggerPointLst = tempLst; } info = _resultInfo; return(hasHit); }
public CamFilterIntent createFilterIntent() { CameraInFluenceController controller = GetComponent <CameraInFluenceController>(); CamFilterIntent tempCamFilterIntent = new CamFilterIntent(); tempCamFilterIntent.followTargetGhost = controller.ghostTarget; tempCamFilterIntent.layerMask = controller.layerMask; tempCamFilterIntent.requireComponentArr = null; tempCamFilterIntent.colliderRadius = 1f; return(tempCamFilterIntent); }