Skip to content

Commit

Permalink
pqHandle never needs to be null
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Oct 24, 2015
1 parent ca3dd84 commit 80995bc
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 56 deletions.
28 changes: 11 additions & 17 deletions libtess.cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2130,8 +2130,7 @@ libtess.sweep.checkForRightSplice_ = function(tess, regUp) {

} else if (eUp.org !== eLo.org) {
// merge the two vertices, discarding eUp.org
// TODO(bckenny): fix pqHandle null situation
tess.pq.remove(/** @type {libtess.PQHandle} */(eUp.org.pqHandle));
tess.pq.remove(eUp.org.pqHandle);
libtess.sweep.spliceMergeVertices_(tess, eLo.oPrev(), eUp);
}

Expand Down Expand Up @@ -4212,15 +4211,12 @@ libtess.GluMesh.prototype.checkMesh = function() {
* circular list, and a pointer to a half-edge with this vertex as
* the origin (null if this is the dummy header). There is also a
* field "data" for client data.
*
* @param {libtess.GluVertex=} opt_nextVertex [description].
* @param {libtess.GluVertex=} opt_prevVertex [description].
* @param {libtess.GluVertex=} opt_nextVertex Optional reference to next vertex in the vertex list.
* @param {libtess.GluVertex=} opt_prevVertex Optional reference to previous vertex in the vertex list.
* @constructor
* @struct
*/
libtess.GluVertex = function(opt_nextVertex, opt_prevVertex) {
// TODO(bckenny): reverse order of params?

/**
* Next vertex (never null).
* @type {!libtess.GluVertex}
Expand Down Expand Up @@ -4266,12 +4262,11 @@ libtess.GluVertex = function(opt_nextVertex, opt_prevVertex) {
this.t = 0;

/**
* To allow deletion from priority queue.
* @type {?libtess.PQHandle}
* Handle to allow deletion from priority queue, or 0 if not yet inserted into
* queue.
* @type {libtess.PQHandle}
*/
this.pqHandle = null;
// NOTE(bckenny): pqHandle inited in sweep
// TODO(bckenny): can we have a numeric default value? null may do bad things
this.pqHandle = 0;
};


Expand Down Expand Up @@ -4511,11 +4506,11 @@ libtess.PriorityQ.prototype.init = function() {
// #endif
};


/**
* [insert description]
* @param {libtess.PQKey} keyNew [description].
* @return {libtess.PQHandle} [description].
* Insert a PQKey into the priority queue. Returns a PQHandle to refer to it,
* which will never be 0.
* @param {libtess.PQKey} keyNew
* @return {libtess.PQHandle}
*/
libtess.PriorityQ.prototype.insert = function(keyNew) {
// NOTE(bckenny): originally returned LONG_MAX as alloc failure signal. no
Expand All @@ -4538,7 +4533,6 @@ libtess.PriorityQ.prototype.insert = function(keyNew) {
return -(curr + 1);
};


/**
* Allocate a PQKey array of size size. If oldArray is not null, its
* contents are copied to the beginning of the new array. The rest of the array
Expand Down
28 changes: 11 additions & 17 deletions libtess.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2142,8 +2142,7 @@ libtess.sweep.checkForRightSplice_ = function(tess, regUp) {

} else if (eUp.org !== eLo.org) {
// merge the two vertices, discarding eUp.org
// TODO(bckenny): fix pqHandle null situation
tess.pq.remove(/** @type {libtess.PQHandle} */(eUp.org.pqHandle));
tess.pq.remove(eUp.org.pqHandle);
libtess.sweep.spliceMergeVertices_(tess, eLo.oPrev(), eUp);
}

Expand Down Expand Up @@ -4278,15 +4277,12 @@ libtess.GluMesh.prototype.checkMesh = function() {
* circular list, and a pointer to a half-edge with this vertex as
* the origin (null if this is the dummy header). There is also a
* field "data" for client data.
*
* @param {libtess.GluVertex=} opt_nextVertex [description].
* @param {libtess.GluVertex=} opt_prevVertex [description].
* @param {libtess.GluVertex=} opt_nextVertex Optional reference to next vertex in the vertex list.
* @param {libtess.GluVertex=} opt_prevVertex Optional reference to previous vertex in the vertex list.
* @constructor
* @struct
*/
libtess.GluVertex = function(opt_nextVertex, opt_prevVertex) {
// TODO(bckenny): reverse order of params?

/**
* Next vertex (never null).
* @type {!libtess.GluVertex}
Expand Down Expand Up @@ -4332,12 +4328,11 @@ libtess.GluVertex = function(opt_nextVertex, opt_prevVertex) {
this.t = 0;

/**
* To allow deletion from priority queue.
* @type {?libtess.PQHandle}
* Handle to allow deletion from priority queue, or 0 if not yet inserted into
* queue.
* @type {libtess.PQHandle}
*/
this.pqHandle = null;
// NOTE(bckenny): pqHandle inited in sweep
// TODO(bckenny): can we have a numeric default value? null may do bad things
this.pqHandle = 0;
};


Expand Down Expand Up @@ -4579,11 +4574,11 @@ libtess.PriorityQ.prototype.init = function() {
// #endif
};


/**
* [insert description]
* @param {libtess.PQKey} keyNew [description].
* @return {libtess.PQHandle} [description].
* Insert a PQKey into the priority queue. Returns a PQHandle to refer to it,
* which will never be 0.
* @param {libtess.PQKey} keyNew
* @return {libtess.PQHandle}
*/
libtess.PriorityQ.prototype.insert = function(keyNew) {
// NOTE(bckenny): originally returned LONG_MAX as alloc failure signal. no
Expand All @@ -4606,7 +4601,6 @@ libtess.PriorityQ.prototype.insert = function(keyNew) {
return -(curr + 1);
};


/**
* Allocate a PQKey array of size size. If oldArray is not null, its
* contents are copied to the beginning of the new array. The rest of the array
Expand Down
2 changes: 1 addition & 1 deletion libtess.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions src/mesh/GluVertex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright 2000, Silicon Graphics, Inc. All Rights Reserved.
* Copyright 2012, Google Inc. All Rights Reserved.
* Copyright 2015, Google Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -34,15 +34,12 @@
* circular list, and a pointer to a half-edge with this vertex as
* the origin (null if this is the dummy header). There is also a
* field "data" for client data.
*
* @param {libtess.GluVertex=} opt_nextVertex [description].
* @param {libtess.GluVertex=} opt_prevVertex [description].
* @param {libtess.GluVertex=} opt_nextVertex Optional reference to next vertex in the vertex list.
* @param {libtess.GluVertex=} opt_prevVertex Optional reference to previous vertex in the vertex list.
* @constructor
* @struct
*/
libtess.GluVertex = function(opt_nextVertex, opt_prevVertex) {
// TODO(bckenny): reverse order of params?

/**
* Next vertex (never null).
* @type {!libtess.GluVertex}
Expand Down Expand Up @@ -88,10 +85,9 @@ libtess.GluVertex = function(opt_nextVertex, opt_prevVertex) {
this.t = 0;

/**
* To allow deletion from priority queue.
* @type {?libtess.PQHandle}
* Handle to allow deletion from priority queue, or 0 if not yet inserted into
* queue.
* @type {libtess.PQHandle}
*/
this.pqHandle = null;
// NOTE(bckenny): pqHandle inited in sweep
// TODO(bckenny): can we have a numeric default value? null may do bad things
this.pqHandle = 0;
};
11 changes: 5 additions & 6 deletions src/priorityq/PriorityQ.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright 2000, Silicon Graphics, Inc. All Rights Reserved.
* Copyright 2012, Google Inc. All Rights Reserved.
* Copyright 2015, Google Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -161,11 +161,11 @@ libtess.PriorityQ.prototype.init = function() {
// #endif
};


/**
* [insert description]
* @param {libtess.PQKey} keyNew [description].
* @return {libtess.PQHandle} [description].
* Insert a PQKey into the priority queue. Returns a PQHandle to refer to it,
* which will never be 0.
* @param {libtess.PQKey} keyNew
* @return {libtess.PQHandle}
*/
libtess.PriorityQ.prototype.insert = function(keyNew) {
// NOTE(bckenny): originally returned LONG_MAX as alloc failure signal. no
Expand All @@ -188,7 +188,6 @@ libtess.PriorityQ.prototype.insert = function(keyNew) {
return -(curr + 1);
};


/**
* Allocate a PQKey array of size size. If oldArray is not null, its
* contents are copied to the beginning of the new array. The rest of the array
Expand Down
2 changes: 1 addition & 1 deletion src/render.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright 2000, Silicon Graphics, Inc. All Rights Reserved.
* Copyright 2014, Google Inc. All Rights Reserved.
* Copyright 2015, Google Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down
5 changes: 2 additions & 3 deletions src/sweep.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright 2000, Silicon Graphics, Inc. All Rights Reserved.
* Copyright 2012, Google Inc. All Rights Reserved.
* Copyright 2015, Google Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -694,8 +694,7 @@ libtess.sweep.checkForRightSplice_ = function(tess, regUp) {

} else if (eUp.org !== eLo.org) {
// merge the two vertices, discarding eUp.org
// TODO(bckenny): fix pqHandle null situation
tess.pq.remove(/** @type {libtess.PQHandle} */(eUp.org.pqHandle));
tess.pq.remove(eUp.org.pqHandle);
libtess.sweep.spliceMergeVertices_(tess, eLo.oPrev(), eUp);
}

Expand Down

0 comments on commit 80995bc

Please sign in to comment.