Skip to content

Why are vectors a struct? #11

@awsdert

Description

@awsdert

Looking at the headers I saw this:

struct vector3 {
	union {
		HYP_FLOAT v[3];
		struct {
			HYP_FLOAT x, y, z;
		};
		struct {
			HYP_FLOAT yaw, pitch, roll;
		};
	};
};

Why bother with the outer struct when you could've done this:

union vector3 {
	HYP_FLOAT v[3];
	struct {
		HYP_FLOAT x, y, z;
	};
	struct {
		HYP_FLOAT yaw, pitch, roll;
	};
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions