Skip to content

Defold native extension that combines two math libraries that avoid allocations

License

Notifications You must be signed in to change notification settings

thinknathan/def-setv

Repository files navigation

Def-Setv

SetV for Defold

Build with bob GitHub License

A Defold native extension that combines the math functions that avoid allocations from Justin Walsh's xmath and Indiesoft LLC's defold-scene3d.

All functions take an output vector (or quaternion, or matrix) as their first argument, and change the vector's values in place instead of allocating a new vector.

Provided Functions

  • setv.get_position
  • setv.get_world_position
  • setv.get_rotation
  • setv.get_world_rotation
  • setv.get_scale
  • setv.get_world_scale
  • setv.world_to_local_position
  • setv.world_to_local_transform
  • setv.add
  • setv.sub
  • setv.mul
  • setv.div
  • setv.cross
  • setv.mul_per_elem
  • setv.normalize
  • setv.rotate
  • setv.vector
  • setv.quat_conj
  • setv.quat_axis_angle
  • setv.quat_basis
  • setv.quat_from_to
  • setv.quat_rotation_x
  • setv.quat_rotation_y
  • setv.quat_rotation_z
  • setv.quat
  • setv.lerp
  • setv.slerp
  • setv.matrix_axis_angle
  • setv.matrix_from_quat
  • setv.matrix_frustum
  • setv.matrix_inv
  • setv.matrix_look_at
  • setv.matrix_orthographic
  • setv.matrix_ortho_inv
  • setv.matrix_perspective
  • setv.matrix_rotation_x
  • setv.matrix_rotation_y
  • setv.matrix_rotation_z
  • setv.matrix_translation
  • setv.matrix

Installation

  1. Edit game.project
  2. Add dependency https://github.com/thinknathan/def-setv/archive/main.zip for the current version

TypeScript Definitions

This extension includes types for use with TypeScript + Defold.

  1. Install these types
yarn add git+https://git@github.com/thinknathan/def-setv.git#^1.0.0 -D
# or
npm install git+https://git@github.com/thinknathan/def-setv.git#^1.0.0 --save-dev
  1. Add def-setv to types in tsconfig.json
{
	"compilerOptions": {
		"types": [
+			"def-setv",
		],
	}
}
  1. Add node_modules/@types to typeRoots in tsconfig.json if it's not already there
{
	"compilerOptions": {
		"typeRoots": [
+			"node_modules/@types",
		],
	}
}

License

MIT

Comments are adapted from Defold's code comments.