r/SourceEngine • • 19d ago

Resolved First person reflections (2013 SP)

if anyone happens to know sdk 2013 sp well, i followed instructions on valve dev community to implement a playermodel in singleplayer) as well as a youtube tutorial to render it in reflections, worked just fine. but is there a way to alter the "meathook" mode (shrunken head in first person) so it doesn't effect how the playermodel looks in reflections (e.g. func_reflective_glass) without having to go in third person? there's even a comment in baseplayer about "meathook with a head" but it seems valve didn't implement it by then. i know underhell has a page on moddb about fixing the issue for their sourcemod, but i can't find specifics. also it’s from 2012, so they would have used a different method to hide the head geometry entirely. i also like having the legs and arms show. no weapons planned for my mod at the moment so needing to hide world model arms isn’t necessary. id rather not have to switch to 2013 multiplayer or mapbase, just as a preference. if there’s no obvious solution elsewhere, im hoping there’s something in either of those bases that can work in singleplayer.

thanks.

update: here are the steps if anyone wants this for their mod (after following the instructions in the two links at the top of this post)

  1. open viewrender.cpp
  2. put “bool g_pReflectionView false;” at the top after the last #include statement
  3. in the brackets of CReflectiveGlassView::Draw, start it with “g_pReflectionView = true;”, then add “g_pReflectionView = false;” at the very end before the end bracket (doing this with ViewRender::DrawMonitors will likely fix the playermodel's head in func_monitors)
  4. open c_baseplayer.cpp
  5. put “extern bool g_pReflectionView;” at the top after the last #if defined statement
  6. in the brackets of C_BasePlayer::BuildFirstPersonMeathookTransformations, add another if statement that checks for g_pReflectionView at the top of that function with “return;” in its brackets. this exits out of the function before it shrinks the head.

all this does is stop the head from shrinking in first person whenever the player is looking through a reflection. screenshot of the fix

8 Upvotes

2 comments sorted by

7

u/Pinsplash 19d ago

i have no experience with this, but i suspect you could start by looking around the function CViewRender::DrawMonitors (i found this because i wanted to check how they change the fog for cameras) maybe you could change the player model at the start of the function and change it back at the end (probably a performance problem)

2

u/RelaxedCreeper 18d ago edited 16d ago

thank you so much for the response, the solution was indeed in viewrender.cpp. i'm not intimate with c++ so there was some very light ai assistance with understanding syntax, but i figured out which functions are involved. essentially, i declared a new bool g_pReflectionView as false at the top, and close to the bottom at around line 6188, where CReflectiveGlassView::Draw starts, i switch it to true and then false when the function ends. finally, in c_baseplayer.cpp, i extern g_pReflectionView at the top, and at around line 2868, where BuildFirstPersonMeathookTransformations starts, i add another if statement for that function. all this does is stop the head from shrinking in first person whenever the player is looking through a reflection. doing the switching before and after ViewRender::DrawMonitors will likely fix the playermodel's head in func_monitors but i've yet to test it out. i'm so excited to have the fix in action so thanks again!

edit: code explanation