简体   繁体   English

SceneKit –几何穿透

[英]SceneKit – Geometry penetration

I import a 3D model into the ScenekKit, then change the Euler's angle of the limb and let the limbs do the action. 我将3D模型导入ScenekKit,然后更改肢体的Euler角度并让肢体执行动作。 However, at this time, clothes and limbs will penetrate. 但是,这时衣服和四肢会渗透。 How can I handle this situation? 我该如何处理这种情况?

在此处输入图片说明

I think you have to use continuousCollisionDetectionThreshold instance property. 我认为您必须使用continuousCollisionDetectionThreshold实例属性。 This value gives you a minimum distance the body must travel for SceneKit to apply a more precise (but more CPU/GPU costly) algorithm to detect contacts with other bodies. 该值为您提供了人体必须经过的最小距离,以便SceneKit应用更精确的算法(但会花费更多的CPU / GPU)来检测与其他物体的接触。

var continuousCollisionDetectionThreshold: CGFloat { get set }

SceneKit's physics engine can employ two kinds of collision detection : SceneKit的物理引擎可以采用两种碰撞检测

  • With discrete collision detection, when SceneKit simulates physics before rendering each frame (see timeStep and SCNSceneRendererDelegate ), it updates the position of each physics body based on the body's velocity during that time interval, then checks to see whether the body at its new position intersects other bodies. 通过discrete collision检测,当SceneKit在渲染每一帧之前模拟物理过程时(请参见timeStepSCNSceneRendererDelegate ),它将根据该时间间隔内物体的速度来更新每个物理物体的位置,然后检查该物体在其新位置是否相交其他身体。

  • With continuous collision detection, SceneKit calculates the volume that will be traversed by a body during each frame, then checks to see whether that volume intersects other bodies. 通过continuous collision检测,SceneKit会计算物体在每一帧中要遍历的体积,然后检查该体积是否与其他物体相交。 This property's value defaults to 0.0 , resulting in discrete collision detection at all times. 此属性的值defaults to 0.0 ,从而始终导致离散冲突检测。 When this value is nonzero, SceneKit applies continuous collision whenever the body travels more than the specified distance within one timeStep . 当此值不为零时,只要身体在timeStep内行进超过指定距离,SceneKit就会应用连续碰撞。

Discrete collision detection offers high performance, but can lead to inaccurate results for small, fast-moving bodies. 离散碰撞检测可提供高性能,但对于小型快速移动的物体可能会导致结果不准确。 Continuous collision detection has a performance cost and works only for spherical physics shapes, but provides more accurate results. 连续碰撞检测具有性能成本,并且仅适用于球形物理形状,但可以提供更准确的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM