You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: heightmap.rs
    path of file: ./repos/Egregoria/geom/src
    
    the code of the file until where you have to start completion: use crate::{vec2, vec3, Ray3, Vec2, Vec3, AABB, AABB3};
use serde::de::{SeqAccess, Visitor};
use serde::ser::SerializeSeq;
use serde::{Deserialize, Serialize, Serializer};

pub type HeightmapChunkID = (u16, u16);

const MAX_HEIGHT_DIFF: f32 = 2048.0;
const HALF_HEIGHT_DIFF: f32 = MAX_HEIGHT_DIFF / 4.0; // Point where half of the precision goes to
const MIN_HEIGHT: f32 = -39.96997;
const MAX_HEIGHT: f32 = MAX_HEIGHT_DIFF - MIN_HEIGHT;

/// Special value for heights_override to indicate that the height is not overridden
pub const NO_OVERRIDE: u16 = 0;

#[derive(Clone)]
pub struct HeightmapChunk<const RESOLUTION: usize, const SIZE: u32> {
    heights: [[u16; RESOLUTION]; RESOLUTION], // TODO: change to RESOLUTION * RESOLUTION when generic_const_exprs is stabilized
    heights_override: 
    
    pub fn height_gradient(&self, p: Vec2) -> Option<(f32, Vec2)> {
        let exact = self.height_nearest(p);
        if let (Some(ll), Some(lr), Some(ul), Some(ur)) = (
            exact,
            self.height_nearest(p + Vec2::x(Self::CELL_SIZE)),
            self.height_nearest(p + Vec2::y(Self::CELL_SIZE)),
            self.height_nearest(p + vec2(Self::CELL_SIZE, Self::CELL_SIZE)),
        ) {
            let x = (p.x / Self::CELL_SIZE).fract();
            let y = (p.y / Self::CELL_SIZE).fract();

            let h01 = ll + x * (lr - ll);
            let h23 = ul + x * (ur - ul);

            let height = h01 + y * (h23 - h01);
            let gradient = -vec2(
                (lr - ll) + y * ((ur - ul) - (lr - ll)),
                (ul - ll) + x * ((ur - lr) - (ul - ll)),
            );

            return Some((height, gradient));
        }
        exact.zip(Some(Vec2::ZERO))
    }