#author("2023-12-30T16:34:03+00:00","default:iseki","iseki")
** SIM Boundary [#obc15ec7]
- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs 
- Simulate() 関数内の actor.UpdatePositionAndVelocity() へチェックコードを追加.
#author("2023-12-31T04:52:50+00:00","default:iseki","iseki")

 if (actor != null) { 
    actor.UpdatePositionAndVelocity();
 
    // by Fumi.Iseki  for falling at SIM boundary
    d.Vector3 vec = d.BodyGetPosition(actor.Body);
 
    if (vec.Y<=0.0f || vec.Y>=255.95f || vec.X<=0.0f || vec.X>=255.95f) {
        if      (vec.Y<=0.0f)   vec.Y = 0.1f; 
        else if (vec.Y>255.95f) vec.Y = 255.95f;
        if      (vec.X<=0.0f)   vec.X = 0.1f; 
        else if (vec.X>255.95f) vec.X = 255.95f;
 
        float height = GetTerrainHeightAtXY(Vec.X, Vec.Y);
        if (actor.Flying) {
            if (vec.Z  <  height + 2) {
                vec.Z = height + actor.Size.Z/2;
                actor.Velocity.Z = 0;
                actor.IsColliding = true; 
            }
        }
        else {
            if (vec.Z < height + actor.Size.Z/2) {
                vec.Z = height + actor.Size.Z/2;
                actor.Velocity.Z = 0;
                actor.IsColliding = true; 
                actor.CollidingGround = true; 
            }
        }
 
        actor.Position = new PhysicsVector(vec.X, vec.Y, vec.Z); 
        d.BodySetPosition(actor.Body, vec.X, vec.Y, vec.Z); 
    }       
 }


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 ページ一覧 検索 最終更新   ヘルプ   最終更新のRSS