ios – Clean mannequin created in Blender has floor imperfections in SceneKit

So, this is likely to be a SceneKit/iOS downside — however it would possibly as a substitute be a Blender downside. This query presupposes the previous.

To illustrate I open a recent venture in Blender (nothing fancy) and export the default dice it creates as a dae file. I then import that dae file into my Xcode SceneKit venture.

This explicit SceneKit venture consists of a scene during which a small ball rolls round on the highest floor of a dice.

The issue: If I exploit SceneKit’s built-in SCNBox form for the dice (with a static, convexHull physics physique), the ball rolls easily, as desired. But when I exploit the mannequin exported from Blender, the ball bounces alongside the dice’s floor as if it had been coated in small, invisible bumps.

What I’ve tried:

  1. I attempted growing the ball’s mass from 2.0 to 100.0 simply to see if that might have an effect on the result.
  2. I attempted making use of some smoothing modifiers to the mannequin in Blender in hopes that it will be freed from imperfections.
  3. I attempted changing the dae file to SceneKit’s personal scn file.
  4. I attempted configuring the SCNPhysicsShape‘s choices parameter in numerous methods, together with the usage of .scale, .sort, .collisionMargin, and .keepAsCompound. Instance:
let form = SCNPhysicsShape(node: dice, choices: [.scale: cube.scale, .collisionMargin: 0.1])
  1. I attempted altering the friction and restitution of each the dice and ball. Much less friction/restitution didn’t remedy the issue, nor did extra of it.
  2. I attempted disabling steady collision detection by eradicating the ball’s continuousCollisionDetectionThreshold.

I am undecided how the next code will assist diagnose this downside, however right here it’s anyway:

//Create the dice's physics physique:
let form = SCNPhysicsShape(node: dice)             
dice.physicsBody = SCNPhysicsBody(sort: .static, form: form)

dice.physicsBody?.categoryBitMask = CollisionTypes.flooring.rawValue
dice.physicsBody?.collisionBitMask = CollisionTypes.dynamicObjects.rawValue
dice.physicsBody?.contactTestBitMask = CollisionTypes.nothing.rawValue
dice.physicsBody?.isAffectedByGravity = false
dice.physicsBody?.allowsResting = false
dice.physicsBody?.restitution = 0.5
dice.physicsBody?.friction = 0.75

//Create the ball's physics physique:
let ballGeo = SCNSphere(radius: 0.5)
ballNode?.physicsBody = SCNPhysicsBody(
   sort: .dynamic,
   form: SCNPhysicsShape(
        geometry: ballGeo
ballNode?.physicsBody?.categoryBitMask = CollisionTypes.dynamicObjects.rawValue
ballNode?.physicsBody?.contactTestBitMask = CollisionTypes.staticObjects.rawValue
ballNode?.physicsBody?.collisionBitMask = CollisionTypes.staticObjects.rawValue | CollisionTypes.flooring.rawValue
ballNode?.physicsBody?.allowsResting = false
ballNode?.physicsBody?.continuousCollisionDetectionThreshold = 0.9 //Tried it with and with out this property.
ballNode?.physicsBody?.restitution = 0.5
ballNode?.physicsBody?.cost = 4.0
ballNode?.physicsBody?.friction = 0.2
ballNode?.physicsBody?.rollingFriction = 1.0
ballNode?.physicsBody?.angularDamping = 0.4
ballNode?.physicsBody?.mass = 2.0

Query: Why would possibly this downside be occurring? Is it a SceneKit downside, as this query presupposes — or is it a Blender downside about which I might want to submit a query on one other discussion board?

See also  ios - Crash associated to UICollectionViewDiffableDataSource

Thanks on your assist.

Leave a Reply