Skip to content

Instantly share code, notes, and snippets.

View ntrf's full-sized avatar
🛅
Gone from GH

Anton Nesterov ntrf

🛅
Gone from GH
View GitHub Profile
@ntrf
ntrf / 1-QuickClipExplanation.md
Last active June 18, 2024 18:15
QuickClip explanation.

Each entity in source engine has two hitboxes - one in quake physics world, and another in havok (or vphys) physics world. This second hitbox is called "physics shadow".

Depending on type of the entity one of the hitboxes is dominant. Each frame results of havok physics simulation for barrels, rollermines, vehicles and etc will be copied over quake hitboxes of entities. For NPCs, rockets and elevators state is copied in reverse direction - quake to havok.

Player is special. Normally quake hitbox will overwrite havok shadow, but only if its movement is not blocked by any havok hitboxes. Player's hitbox will be copied in reverse - from havok to quake - if (a) havok hitbox is valid (not stuck in quake world), (b) player is touching a vphys object.

Quickclip works, because in vehicles havok hitbox has collisions masked out for everything except pickups (health, ammo). When you exit a vehicle, collision mask for havok physics should be changed to normal, but only if vehicle is present in the world. Barnacle fo

@ntrf
ntrf / main.dart
Last active September 22, 2023 23:33
IdontNeedForLoops
// Don't you ever write code like this.
// -- Ntrf
import 'dart:math';
int waterTrapped(List<int> heights) {
int maxFwd = 0;
int maxRev = 0;
int res = heights.fold(0, (a, x) => a + (maxFwd = max(maxFwd, x)));
res += heights.reversed.fold(0, (a, x) => a + (maxRev = max(maxRev, x)));