Skip to content
Snippets Groups Projects

Add "drawonlyforplayer" and "dontdrawforviewmobj"

Merged Zwip-Zwap Zapony requested to merge Zwip-Zwap_Zapony/SRB2:drawonlyforpx into next
1 unresolved thread

Mobjs now have a drawonlyforplayer field. If set to a player_t, hides the mobj for everyone except this player and their spectators.
Mobjs also have a dontdrawforviewmobj field. If set to a mobj_t, hides the mobj if dontdrawforviewmobj is the current camera (first-person player or awayviewmobj).
These fields can stack, and they work online as well as in splitscreen. They're exposed to Lua, and also utilised by the vanilla game.

Lock-on arrows, Tailsbot's flight indicator, CTF flag-carrier signs, and Tag "IT" signs now handle splitscreen (and no longer show up for you when you spectate someone else), shields can no longer show up in first-person (fixes #924 (closed), fixes #997 (closed)), co-op finish flags no longer disappear for all players when you're in first-person (fixes #1009 (closed)), Metal Sonic's jet bubbles when underwater and jet trail in Boost Mode are now hidden in first-person (is this change desirable?).

MT_OVERLAY objects copy their target's dontdrawforviewmobj field, but not drawonlyforplayer. Lua can override this with e.g. PostThinkFrame hooks, of course.

[This Lua script] adds a drawonlyforplayer # console command. Replace # with 1 to make all current objects only render for player 1, 2 for player 2, or 0 for both players.
It also adds a dontdrawforviewmobj # console command. Replace # with 1 to make all current objects be hidden for player 1 while in first-person, 2 for player 2, 0 for neither, or "self" for when awayviewcam is in use.
It also adds a splitrings console variable, enabled by default, which makes Rings work per-player by cloning them and making each set only render for and be collected by a specific player. This is only a proof of concept.

-

TL;DR:
- Added drawonlyforplayer and dontdrawforviewmobj to control object visibility per-player, even in splitscreen
- Fixed many inconsistencies with objects being visible/invisible when they shouldn't be for certain players, especially in splitscreen
- Fixed some shields being visible in first-person when using 3D models
- Fixed Metal Sonic's jet fume being visible in first-person when moving backwards with Speed Shoes
- Metal Sonic's Boost Mode trail and underwater bubbles are no longer visible in first-person

Edited by Zwip-Zwap Zapony

Merge request reports

Checking pipeline status.

Approval is optional

Merged by SalSal 1 year ago (Jul 25, 2023 3:06pm UTC)

Merge details

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • ChaoLoveIceMDBoy mentioned in merge request !1989 (closed)

    mentioned in merge request !1989 (closed)

  • sphere added Bug label

    added Bug label

  • added Feature label

  • sphere changed milestone to %2.2.12

    changed milestone to %2.2.12

  • added SRB2Kart port label

  • sphere approved this merge request

    approved this merge request

  • sphere mentioned in merge request !1891 (closed)

    mentioned in merge request !1891 (closed)

    • Contributor

      I think this is a strange thing to port, as the person who coded this feature.

      This is the old Kart implementation which is incredibly clunky, and I do not think it is a good idea anymore. Ring Racers handles it by replacing the DONTDRAW flag system entirely, which you can't really do in a patch.

      SRB2's splitscreen usage is extremely minimal compared to Kart. These flags were implemented to make Hyudoro work in a game explicitly designed for couch-play (down to us making HUD redesigns for every screen combination). In SRB2, splitscreen is kind of just there, and there's no game mechanics designed around visibility. I don't really think it's a good idea to solve extremely minor issues by introducing an incredibly antiquated and convoluted method.

      What would probably be both more useful overall and less bloated would be adding two extra mobj_t variables:

      • A pointer to an mobj_t. If this pointer is the current camera (either 1st person player, or awayviewcam) then draw it invisible.
      • A pointer to a player_t. If this pointer is non-NULL, then make it only draw on this player's screen.

      These would cover everything vanilla would need this for without introducing insane bloat.

    • Currently, this merge request aims for familiarity with SRB2Kart's system. If I want to aim for familiarity with Dr. Robotnik's Ring Racers' system instead, are those pointers what Ring Racers (currently) uses, what are they called, and where are they placed in the mobj_t struct?

      [...] These would cover everything vanilla would need this for [...]

      Technically, vanilla SRB2 also has a "hide a mobj from a specific player, in both first- and third-person" case for CTF flag/Tag "IT" indicators, which that system doesn't allow. (In practice, that can be accomplished by "not spawning it for the local player online" and "only showing it for the opposite player in splitscreen", but it would require spawning three copies of the mobj if SRB2 gets 4-player splitscreen someday.)

    • Contributor

      I said in my post RR replaces DONTDRAW entirely. Its system isn't portable without breaking every mod imaginable. I was making suggestions for possible alternative systems that wouldn't break anything. You could just add a third pointer for that last scenario, y'know; maybe slightly redundant but not as bad as taking up a varying number of eflags imo.

    • Please register or sign in to reply
  • Zwip-Zwap Zapony marked this merge request as draft

    marked this merge request as draft

  • sphere unapproved this merge request

    unapproved this merge request

  • Zwip-Zwap Zapony added 73 commits

    added 73 commits

    Compare with previous version

  • Zwip-Zwap Zapony marked this merge request as ready

    marked this merge request as ready

  • Zwip-Zwap Zapony changed title from Draft: Port and Utilise MFE_DRAWONLYFORPx from SRB2Kart to Add "drawonlyforplayer" and "dontdrawforviewmobj"

    changed title from Draft: Port and Utilise MFE_DRAWONLYFORPx from SRB2Kart to Add "drawonlyforplayer" and "dontdrawforviewmobj"

  • Zwip-Zwap Zapony changed the description

    changed the description

  • This merge request previously ported SRB2Kart's MFE_DRAWONLYFORPx flags, but now uses a player and/or viewmobj pointer system.

  • removed SRB2Kart port label

  • added Lua label

  • added Refactoring label

  • Sal added 173 commits

    added 173 commits

    Compare with previous version

  • Sal merged

    merged

  • Sal mentioned in commit 7c26fbf0

    mentioned in commit 7c26fbf0

  • Zwip-Zwap Zapony mentioned in merge request !2125 (merged)

    mentioned in merge request !2125 (merged)

  • Zwip-Zwap Zapony mentioned in issue #1216

    mentioned in issue #1216

Please register or sign in to reply
Loading