jonigata commited on
Commit
61501e2
·
1 Parent(s): ee3a573

fix infinite loop on cut off

Browse files
Files changed (1) hide show
  1. static/poseEditor.js +6 -4
static/poseEditor.js CHANGED
@@ -26,10 +26,11 @@ function cutOffLimb(pose, cutOffIndex) {
26
  // 末端ノードの座標を削除する
27
  var newPose = deepCopy(pose);
28
  for (let i = 0; i < 18; i++) {
 
29
  // ルートまで検索し、その間にcuttOffIndexがあれば削除
30
- if (i == 1) {continue;} // ルートは削除しない
31
  var curr = i;
32
- while (true) {
 
33
  let parent = findParentNodeIndex(curr);
34
  if (parent === cutOffIndex) {
35
  console.log(`cutOffLimb: ${i} -> ${cutOffIndex}`);
@@ -432,8 +433,9 @@ function handleMouseDown(event) {
432
  if (keyDownFlags["KeyD"]) {removePerson(personIndex);return;}
433
  if (keyDownFlags["KeyR"]) {repairPerson(personIndex);return;}
434
 
435
- if (keyDownFlags["KeyQ"] && minDist < 16 && nodeIndex != 1) {
436
- // cutOffPersonLimb(personIndex, nodeIndex);
 
437
  return;
438
  }
439
 
 
26
  // 末端ノードの座標を削除する
27
  var newPose = deepCopy(pose);
28
  for (let i = 0; i < 18; i++) {
29
+ if (newPose[i] == null) {continue;}
30
  // ルートまで検索し、その間にcuttOffIndexがあれば削除
 
31
  var curr = i;
32
+ while (curr !== 1) {
33
+ console.log(`checking: ${i} -> ${curr}`);
34
  let parent = findParentNodeIndex(curr);
35
  if (parent === cutOffIndex) {
36
  console.log(`cutOffLimb: ${i} -> ${cutOffIndex}`);
 
433
  if (keyDownFlags["KeyD"]) {removePerson(personIndex);return;}
434
  if (keyDownFlags["KeyR"]) {repairPerson(personIndex);return;}
435
 
436
+ if (keyDownFlags["KeyQ"] && minDist < 16) {
437
+ console.log("pressed KeyQ");
438
+ cutOffPersonLimb(personIndex, nodeIndex);
439
  return;
440
  }
441