local cpml = require "cpml"
-- basic vector manipulation...
local a = cpml.vec3(1, 2, 3)
local b = cpml.vec3(2, 3, 4)
local c = a * b
print(c) -- (+2.000,+6.000,+12.000)
-- you can also access functions using cpml.class.function(a, b)...
print(cpml.vec3.dot(a, b)) -- 20
-- transform a vec3 point into camera space with a matrix...
local camera = cpml.mat4():look_at(cpml.vec3(0, -5, 1.5), cpml.vec3(0, 0, 0))
local pos = m1 * c
-- and much more! check the docs to see what all we've got.
Note: we recently finished a major refactor, so a few things may still be broken.
Last edited by shakesoda on Fri Dec 16, 2016 12:40 am, edited 2 times in total.
Hi Shakesoda,
Not sure if you're still maintaining this lib, but I have a small suggestion for your "octree" class,
How about keeping a table of references (sort of like reverse lookup):
handles[obj] = node
You just need to update this table whenever an object is inserted/removed.
This would make removal of object from the tree much faster as you don't have to search the tree each time.
ivan: we don't have a lookup because of memory concerns, with LD36 (our heaviest use of the octree) we were running into memory limits...
also, updated CPML to v1.2.9, which reverts the out-variable API changes to be friendlier to use again. Everything else from the old refactor branch was kept. The out variables did help performance, but the usage suffered enough that it was just plain frustrating to use, even many months and two LD's later.
Many of your functions return new objects. Consider creating functions that modify objects in place, and use object generating functions as wrappers for those. This way you get functions that don't produce garbage, plus functions that are "fire and forget" style of use.
local function vector_inplace ( ref, x, y, z )
ref.x, ref.y, ref.z = x, y, z
end
local function vector ( x, y, z )
return vector_inplace ( { }, z, y, z )
end
raidho36 wrote:Many of your functions return new objects. Consider creating functions that modify objects in place, and use object generating functions as wrappers for those. This way you get functions that don't produce garbage, plus functions that are "fire and forget" style of use.
local function vector_inplace ( ref, x, y, z )
ref.x, ref.y, ref.z = x, y, z
end
local function vector ( x, y, z )
return vector_inplace ( { }, z, y, z )
end
this is planned for next release, we just wanted the API to be pleasant to use again first.