1

次のスタートアップを使用します。

        BulletSharp.DefaultCollisionConstructionInfo collisionConstructionInfo =
            new BulletSharp.DefaultCollisionConstructionInfo();
        BulletSharp.DefaultCollisionConfiguration collisionConfiguration =
            new BulletSharp.DefaultCollisionConfiguration(
                collisionConstructionInfo );
        BulletSharp.Dispatcher collisionDispatcher =
            new BulletSharp.CollisionDispatcher(
                collisionConfiguration );
        BulletSharp.BroadphaseInterface broadPhaseCollisionInterface =
            new BulletSharp.SimpleBroadphase( );
        BulletSharp.CollisionWorld bulletCollisionWorld =
            new BulletSharp.CollisionWorld(
                collisionDispatcher,
                broadPhaseCollisionInterface,
                collisionConfiguration );

        BulletSharp.ConstraintSolver constraintSolver =
            new BulletSharp.SequentialImpulseConstraintSolver();
        BulletSharp.DynamicsWorld bulletDynamicsWorld =
            new BulletSharp.DiscreteDynamicsWorld(
                collisionDispatcher,
                broadPhaseCollisionInterface,
                constraintSolver,
                collisionConfiguration );

これを 1 秒間に 60 回実行します。

bulletDynamicsWorld.StepSimulation( (float)deltaTime, 9, 1.0F / 40.0F );

次に、後で任意のポイントを終了するときにこれらを呼び出します。

        Utility.SafeDispose( bulletDynamicsWorld );
        Utility.SafeDispose( constraintSolver );
        Utility.SafeDispose( broadPhaseCollisionInterface );
        Utility.SafeDispose( collisionDispatcher );
        Utility.SafeDispose( collisionConfiguration );
        Utility.SafeDispose( bulletCollisionWorld ); <<< The error happens here >>>

強調表示された行を実行すると、次のエラーが発生します。

「ランタイムで致命的なエラーが発生しました。エラーのアドレスは、スレッド 0x1378 の 0x6b1c9704 でした。エラー コードは 0xc0000005 です。このエラーは、CLR のバグか、ユーザー コードの安全でない部分または検証不可能な部分のバグである可能性があります。このバグの一般的な原因には、COM 相互運用機能または PInvoke のユーザー マーシャリング エラーが含まれ、スタックが破損する可能性があります。」

ノート:

1) 箇条書きのコードはこれだけです。衝突オブジェクトまたは動的オブジェクトは追加されていません。

2) Utility.SafeDispose() は IDiposable を受け取り、null 値をチェックし、有効な場合は .Dispose() を呼び出します。

3)明確にするために、言語はC#です。

4) .SafeDispose ステートメントのリスト内の Utility.SafeDispose( CollisionWorld ) の位置は効果がないようです。

クラッシュするのはなぜですか?どうすれば修正できますか?

ありがとう。

4

2 に答える 2

2

bulletCollisionWorld を破棄するときは、broadPhaseCollisionInterface にアクセスして、ワールドによって作成されたコリジョン ペアをクリアします。ワールドを破棄する前に衝突インターフェイスを明示的に破棄するため、ワールドは無効なポインターにアクセスします。

したがって、解決策は、最初に両方の世界を破棄し、次に衝突インターフェイスを破棄することです。

于 2012-10-26T22:20:44.870 に答える
0

DiscreteDynamicsWorld はコリジョン ワールドです。余分なコリジョン ワールドを削除しても、エラーは発生しませんでした。したがって、問題はおそらく 2 つのコリジョン ワールドを持つことでした。いくつかのグローバルがあるようです。

于 2012-10-26T21:27:13.590 に答える