Jump to content
Korean Random
Sign in to follow this  
aks1983

Адские проблемы при использовании onControlModeChanged

Recommended Posts

Делаю переход свободная камера <-> привязанная камера. Штатно это работает по нажатию CAPS+F3, но мне требуется своя реализация.

Код таков:

# sometimes we need to do it
def checkAndRetry(check, retry):
    BigWorld.callback(0.2, lambda: check() and retry())

def switchFreeCamera(attemps=5):
    aih = BigWorld.player().inputHandler

    # enable switchung before battle start
    aih._AvatarInputHandler__isStarted = True

    # 0.9.17 intoduced isObserverFPV
    if not aih.isObserverFPV and attemps > 0:
        prev_mode = aih.ctrlModeName
        if prev_mode == 'video':
            mode = 'postmortem' if BigWorld.player().isObserver() else 'arcade'
            aih.ctrl.setForcedGuiControlMode(False)
            aih.onControlModeChanged(mode, prevModeName=prev_mode)
            checkAndRetry(lambda: aih.ctrlModeName != mode, lambda: switchFreeCamera(attemps - 1))
        else:
            cam_matrix = Math.Matrix(BigWorld.camera().matrix)
            aih.onControlModeChanged('video', prevModeName=prev_mode, camMatrix=cam_matrix)
            # leave inertia for smoother movement
            if BigWorld.player().vehicle is not None:
                aih.ctrl._cam._VideoCamera__velocity = Math.Vector3(BigWorld.player().vehicle.filter.velocity)

В 0.9.17 появился баг - камера улетает под землю, на ghost-танк наблюдателя. При возврате в arcade/postmortem выбирается совсем не тот танк, от которого я отвязывался.

Исследовав метод onControlModeChanged, я ужаснулся его неструктуированности. Практически невозможно понять, как ведёт себя поток исполнения. Нашел конечные точки -
это BigWorld.player().cell.bindToVehicle(vehicleID), BigWorld.player().cell.moveTo(pos) и BigWorld.player().cell.switchViewpoint(toPrevious)
 

Кто-нибудь исследовал этот вопрос?

Edited by aks1983
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...