question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Below are some topics regarding the future of ccpwgl that I’d like to discuss. The following pull request has been created to support this discussion: https://github.com/ccpgames/ccpwgl/pull/196

Matrix Library

Do we want to upgrade to a newer matrix library?

The latest glMatrix library from glMatrix.net (a later version of the one used now) has some performance benefits, a much more logical and consistent argument order (the receiving object is almost always first) vs the current ( the receiving object is either the last or the first argument), more functionality and optimizations.

Benefits:

  • SIMD Support
  • Faster calculations
  • More functionality
  • Some complicated calculations have been reduced to single functions
  • vec2 functions
  • vec4 functions separated from quaternion functions
  • better naming conventions

Penalties:

  • Slightly more verbose in some situations
  • Requires refactoring of ccpwgl
  • Requires testing

Do we want to create and maintain our own library?

While the latest glMatrix.net library has a lot of functionality it is lacking some basic scalar operations (I have included these in the pull request in the file ext.js) and it’s focus excludes any functionality for things like bounding boxes, bounding spheres, ray casting and planes (I have versions of these in testing presently).

There is no need for any of this extra functionality for ccpwgl to work with the new library as it is. Refactoring and replacing the current library is all that would be required.

However, my proposal is:

  • Create and maintain our own library based off the latest glMatrix.net library
  • Extend scalar functionality (without creating a new file with those extensions as seen in my pull request)
  • Keep it separate from any ccpwgl files (as we have now)
  • Keep the different math categories in separate files
  • Provide a grunt process to build this library
  • Migrate all glMatrix and math functions that exist solely in ccpwgl_int to this library
  • Incrementally add non-core functionality (see list below)

I’d like to start adding (or see others adding) useful generic 3d library methods to enable quality applications to be made with minimal effort. Raycasting, colour picking and physics would be at the top of that list :3

I do not see this library having to be upgraded often once implemented so maintenance should be low.

Proposed Files and Folders

/src/math

// base
/src/math/gl3.js - Generic

// core
/src/math/vec2.js - Vector 2
/src/math/vec3.js - Vector 3
/src/math/vec4.js - Vector 4
/src/math/quat.js - Quaternion
/src/math/mat3.js - Matrix 3x3
/src/math/mat4.js - Matrix 4x4

// extended
/src/math/clr.js - Colors
/src/math/box.js - Bounding Box
/src/math/sph.js - Bounding Sphere
/src/math/pln.js - Plane
/src/math/tri.js - Triangle/ Face
/src/math/ray.js - Ray casting

// build
/dist/ccpwgl_gl3.js - Unminified
/dist/ccpwgl_gl3.min.js - Minified

EMCAScript 6 / Typescript

A couple of months back I converted the ccpwgl_int files to ES6 and while I didn’t initially see any benefits as it was a pain to keep up to date, it did make extending the library easier, removed the need for a build process (apart from converting to ES5), made things a little more readable and simplified some of the code.

Would anyone apart from myself benefit from moving to ES6 (or to Typescript as some others have suggested)? And more importantly, would @filipppavlov want to maintain the library in this format. :3 I’d be willing to put in the hours to covert it again (and the 10k or so linting issues as well) but only if it was to become the standard version.

For the immediate future I propose that we introduce some build tasks to create versions of ccpwgl_int and the matrix library that support the ES6 import and export features. Included in the aforementioned pull request there is a working example of how this could work: grunt es6

Proposed Files and Folders

/dist/ccpwgl_int.es6
/dist/ccpwgl_gl3.es6

Compiled Files

Move all compiled files to /dist/. Users of ccpwgl would only need this folder for ccpwgl to work.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
regnercommented, Jul 18, 2016

Any chance of getting an NPM package built and published? Would be really slick to see something like Travis CI building the repo and publishing it.

2reactions
cppctambercommented, Jul 30, 2016

Presently trying to decide on a format for the extended matrix and collidables methods for y’all to consider, of which I have multiple versions. Any input would be appreciated. I’ve included an example for each option which shows how you’d expand a Tw2 meshes’ bounding box by a given point (this isn’t necessarily something you’d want to do, just an example!).

var mesh = ship.wrappedObjects[0].mesh.geometryResource.meshes[0]

Match the style of the glMatrix libraries

/**
 * Copies a box3 to another
 * @param {box3} out - Receiving box3
 * @param{box3} box - Box to copy
 * @returns {box3} out
 */
box3.copy= function (out, box)
{
    out[0] = box[0];
    out[1] = box[1];
    out[2] = box[2];
    out[3] = box[3];
    out[4] = box[4];
    out[5] = box[5];
    return out;
};

...

// example
var bbox = box3.fromBounds(mesh.minBounds, mesh.maxBounds);
box3.addPoint(bbox, [ 100, 100, 100 ]);
box3.toBounds(bbox, mesh.minBounds, mesh.maxBounds);

Helper functions only, suited to ccpwgl’s coding style

/**
 * Copies a bounding box's bounds
 * @param {vec3} outMin- Receiving min bounds
 * @param {vec3} outMax- Receiving max bounds
 * @param {vec3} boxMin - Min bounds to copy
 * @param {vec3} boxMax - Max bounds to copy
 */
box.copy= function (outMin, outMax, boxMin, boxMax)
{
    vec3.copy(outMin, boxMin);
    vec3.copy(outMax, boxMax);
};

...

// example
box.addPoint(mesh.minBounds, mesh.maxBounds, [ 100, 100, 100 ]);

Add new Tw2Parameters

function Tw2BoxParameter(name, minBounds, maxBounds)
{
    this.name = name || '';
    this.min = vec3.fromValues(-Infinity, -Infinity, -Infinity);
    this.max = vec3.fromValues(Infinity, Infinity, Infinity);
    if (minBounds) vec3.copy(this.min, minBounds);
    if (maxBounds) vec3.copy(this.max, maxBounds);
};

Tw2BoxParameter.prototype.Copy = function(box)
{
    vec3.copy(this.min, box.min);
    vec3.copy(this.max, box.max);
};

...

// Example
var bbox = new Tw2BoxParameter('Example Box', mesh.minBounds, mesh.maxBounds);
bbox.addPoint([100,100,100]);
bbox.toArrays(mesh.minBounds, mesh.maxBounds);

New Collidable constructors (wip)

Create a new Tw2CollidableAccumulator constructor and Tw2Collidable constructor which would be used in a similar way to Tw2BatchAccumulator and render batches. Collidables are collected (Planes, SpriteSets, SpotlightSets, Decals, Boosters, Mesh) and then operations are performed on them. All of the extended matrix functions could be added as static methods to these.

function Tw2CollidableAccumulator()
{
    this.collidables = [];
    this.count = 0;
    this._sortFunction = null;
};

Tw2Collidable.Cast = function(rayOrigin, rayDirection, optional, intersected)
{
    // perform ray casting operation on all accumulated collidables
    return intersected;
};

...

function Tw2Collidable(geometryProvider)
{
    this.type = '';
    this.visible = true;
    this.geometryProvider = null;
    this.minBounds = vec3.create();
    this.maxBounds = vec3.create();
    this.boundsSpherePosition = vec3.create();
    this.boundsSphereRadius = 0;
    this.pickingColor = quat4.create();
    this.pickingObjectID = 0;
    this.mode = 0;
    this.usage = Tw2CollidableBatch.BOX;
    this.worldTransform = mat4.create();
    this.transform = mat4.create();
    if (geometryProvider)
    {
        this.SetGeometryProvider(geometryProvider);
    }
};

Tw2Collidable.CopyBox = function(a)
{
    vec3.copy(this.minBounds, a.minBounds);
    vec3.copy(this.maxBounds, a.maxBounds);

    if (this.geometryProvider !== null)
    {
        vec3.copy(this.geometryProvider.minBounds, a.minBounds);
        vec3.copy(this.geometryProvider.maxBounds, a.maxBounds);
    }
};
...

// Example
var bbox = new Tw2Collidable(mesh);
bbox.addPoint([100,100,100]);
...

Extend Tw2Geometry constructors

Extend existing tw2 constructors with relevant methods.

// Example 1 (Updates bounding box and bounding sphere in one go)
mesh.AddPoint([100,100,100]); 

// Example 2
mesh.areas[0].AddPoint([100,100,100]); 
Read more comments on GitHub >

github_iconTop Results From Across the Web

August - December motherlode by cppctamber · Pull Request #265 ...
Added Tw2Error base class and other custom errors in preparation for future Promise support and simplified logging · Replaced all generic logs with...
Read more >
[evedevs] CCP Games on GitHub ~CCP FoxFour : r/evetech - reddit
... to all existing projects and will continue to add it to future ones. ... You can find the CCP WebGL project athttps://github.com/ccpgames/ccpwgl....
Read more >
eve-kino tech-demo 20130627 - YouTube
This is a quite early tech-demo of my newest pet-project: "eve-kino", a browser application using ccpwgl intended for creating (short) videos set in...
Read more >
Will CCP change their mind and once again make ... - EVE Search
They clearly believe that Linux is the gaming OS of the future. My Radeon R9 390 would love native client. ... https://github.com/ccpgames/ccpwgl
Read more >
Dev blog: The Space Object Factory: One File To Rule Them All ...
OK, so how this change will affect the future of ccpwgl project (if there any future at all): Ccpwgl was frozen at current...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found