Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Compiler related camera animation glitch #148

Closed
ShokerStlk opened this issue Nov 11, 2016 · 3 comments
Closed

VS Compiler related camera animation glitch #148

ShokerStlk opened this issue Nov 11, 2016 · 3 comments
Labels
Bug The issue in the run-time.
Projects

Comments

@ShokerStlk
Copy link
Contributor

ShokerStlk commented Nov 11, 2016

Bad english below. (sry)

Во время работы с OpenXRay я заметил что некоторые анимации камеры игрока ведут себя странно - в частности стали слишком ярко выражены.

Легче всего это видно в анимациях стрейфа с оружием (когда мы стоим на месте и вдруг идём влево или вправо): "\gamedata\anims\camera_effects\actor_move\strafe_left.anm" и "\gamedata\anims\camera_effects\actor_move\strafe_right.anm"
Тут в архиве приведён видео-пример - https://www.dropbox.com/s/0j3yrmsncupcyc1/cam_anim_error.zip?dl=0.

С OpenXRay во время их проигрывания оружие скачет чуть ли не на пол экрана.

После поисков удалось обнаружить что причина странного поведения кроется в функции - CAnimatorCamLerpEffector::ProcessCam (ActorEffector.h)

class CAnimatorCamEffector :public CEffectorCam
class CAnimatorCamLerpEffector :public CAnimatorCamEffector
...
BOOL CAnimatorCamLerpEffector::ProcessCam(SCamEffectorInfo& info)
{
       if(!inherited::inherited::ProcessCam(info))	return FALSE;  
//     if(!CAnimatorCamEffector::CEffectorCam::ProcessCam(info))	return FALSE;
        ....

По логике здесь должна вызваться функция CEffectorCam::ProcessCam(), однако по какой то причине вместо неё идёт вызов CAnimatorCamEffector::ProcessCam(). Из за чего вся анимация проигрывается некорректно.

Если эту строку заменить на:

BOOL CAnimatorCamLerpEffector::ProcessCam(SCamEffectorInfo& info)
{
     if(!CEffectorCam::ProcessCam(info))	return FALSE;
        ...

То всё начинает работать "как в оригинале".

Причём самое интересное, что сама студия с IntelSense подсвечивает в той строке ошибку о том, что один из inherited не доступен, т.к является protected\private, однако при этом проект полностью собирается и даже не кидает предупреждение\ошибку. Я посмотрел оригинал, там точно такая-же строка.

error

Получается это какие то "особенности" 2015 студии или C++11?
Как выявлять такие ошибки на стадии компиляции? Ведь сколько ещё мест в движке могут иметь такой-же скрытый "баг".


With OpenXRay some "actor camera animations" (*.anm) becomes broken a bit.
The best example of it is weapon left\right strafe animation. (It plays when you stop and then start to walk left or right with weapon) - "\gamedata\anims\camera_effects\actor_move\strafe_left.anm"_ и "\gamedata\anims\camera_effects\actor_move\strafe_right.anm"
(Video - https://www.dropbox.com/s/0j3yrmsncupcyc1/cam_anim_error.zip?dl=0)

The problem was detected in CAnimatorCamLerpEffector::ProcessCam (ActorEffector.h)

class CAnimatorCamEffector :public CEffectorCam
class CAnimatorCamLerpEffector :public CAnimatorCamEffector
...
BOOL CAnimatorCamLerpEffector::ProcessCam(SCamEffectorInfo& info)
{
       if(!inherited::inherited::ProcessCam(info))	return FALSE;  <<<< THIS CODE FROM ORIG XRay1.6
//     if(!CAnimatorCamEffector::CEffectorCam::ProcessCam(info))	return FALSE;
        ....

In theory it should call "CEffectorCam::ProcessCam(info)" but for some reason it call [only] CAnimatorCamEffector::ProcessCam() instead, which shouldn't be called.

If replace it with:

BOOL CAnimatorCamLerpEffector::ProcessCam(SCamEffectorInfo& info)
{
     if(!CEffectorCam::ProcessCam(info))	return FALSE;
        ....

Then all start to work as intended.

Visual Studio telling me about this eror:
error
But it still compile project without any error\warning, which is bad.

Is such "behavior" related to VS2015 \ C++11? And how to detect\prevent all other similar "errors"?

@ShokerStlk
Copy link
Contributor Author

Проблема возникает только с if ()
http://rextester.com/LVBODH52203 - всё хорошо (ok)
http://rextester.com/JBGUB72847 - не правильный результат (wrong)

@revolucas
Copy link
Contributor

revolucas commented Feb 6, 2017

It has to do with the type definition inherited being set private, It should be protected instead. As you may already know subclasses cannot access private members, only protected.

class CAnimatorCamEffector : public CEffectorCam
{
protected:
typedef CEffectorCam inherited;

Looks like ai_stalker.cpp has a similar problem...which looks to be pretty serious if it's calling CCustomMonster::schedule_Update since then it means it's doing several things twice per update.

nitrocaster pushed a commit that referenced this issue Feb 24, 2017
…x undefined behavior in compiled code)

Close issue #148
@andrew-boyarshin andrew-boyarshin added the Bug The issue in the run-time. label Mar 10, 2017
@Xottab-DUTY Xottab-DUTY added this to In progress in Main flow Jul 1, 2018
@Xottab-DUTY Xottab-DUTY moved this from In progress to To do in Main flow Nov 9, 2018
@SkyLoaderr
Copy link
Contributor

Already fixed

Main flow automation moved this from To do to Done Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug The issue in the run-time.
Projects
No open projects
Main flow
  
Done
Development

No branches or pull requests

5 participants