Skip to content
This repository
Browse code

Version 0.17b

  • Loading branch information...
commit 2504d592572db1a348170c8775bb3a0dbb7b874c 1 parent 7272336
repetier authored
31  RepetierHost/RepetierHost/models/GCodeVisual.m
@@ -30,6 +30,8 @@ @implementation GCodePath
30 30
 -(id)init {
31 31
     if((self=[super init])) {
32 32
         pointsCount = 0;
  33
+        elementsLength = 0;
  34
+        positionsLength = 0;
33 35
         drawMethod = -1;
34 36
         positions = nil;
35 37
         normals = nil;
@@ -130,6 +132,12 @@ -(void)join:(GCodePath*)path
130 132
         }
131 133
         else
132 134
         {
  135
+            if(positions!=nil)
  136
+                free(positions);
  137
+            if(elements!=nil)
  138
+                free(elements);
  139
+            if(normals!=nil)
  140
+                free(normals);
133 141
             elements = nil;
134 142
             normals = nil;
135 143
             positions = nil;
@@ -162,6 +170,7 @@ -(void)free
162 170
         elements = nil;
163 171
         normals = nil;
164 172
         positions = nil;
  173
+        pointsCount = 0;
165 174
         [pointsLists clear];
166 175
         if (hasBuf)
167 176
             glDeleteBuffers(3, buf);
@@ -197,7 +206,8 @@ -(void)refillVBO
197 206
 }
198 207
 -(void)updateVBO:(BOOL)buffer
199 208
 {
200  
-    if (pointsCount < 2) return;
  209
+    if (pointsCount < 2) 
  210
+        return;
201 211
     if (hasBuf)
202 212
         glDeleteBuffers(3, buf);
203 213
     hasBuf = NO;
@@ -377,7 +387,7 @@ -(void)updateVBO:(BOOL)buffer
377 387
             glBindBuffer(GL_ARRAY_BUFFER, buf[1]);
378 388
             glBufferData(GL_ARRAY_BUFFER, (positionsLength * sizeof(float)), normals, GL_STATIC_DRAW);
379 389
             glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf[2]);
380  
-            glBufferData(GL_ELEMENT_ARRAY_BUFFER, (elementsLength * sizeof(int)), elements,GL_STATIC_DRAW);
  390
+            glBufferData(GL_ELEMENT_ARRAY_BUFFER, (elementsLength * sizeof(GLuint)), elements,GL_STATIC_DRAW);
381 391
             // GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
382 392
             hasBuf = YES;
383 393
         }
@@ -476,7 +486,6 @@ -(id)initWithAnalyzer:(GCodeAnalyzer*)a {
476 486
 }        
477 487
 -(void)dealloc
478 488
 {
479  
-    NSLog(@"dealloc GCodeVisual");
480 489
     for (GCodePath *p in segments)
481 490
         [p free];
482 491
     [segments clear];
@@ -508,7 +517,9 @@ -(void)reduce
508 517
         while (actn->next != nil)
509 518
         {
510 519
             next = actn->next;
511  
-            if (next->next == nil) return; // Don't touch last segment we are writing to
  520
+            if (next->next == nil) {
  521
+                return; // Don't touch last segment we are writing to
  522
+            }
512 523
             GCodePath *nextval = next->value;
513 524
             if (nextval->pointsCount < 2)
514 525
             {
@@ -1098,7 +1109,14 @@ -(void)paint
1098 1109
     if (conf3d->disableFilamentVisualization) return; // Disabled too much for card
1099 1110
     hotFilamentLength = conf3d->hotFilamentLength;
1100 1111
     minHotDist = totalDist - hotFilamentLength;
  1112
+    RHLinkedList *sl = [RHLinkedList new];
  1113
+    [changeLock lock];
1101 1114
     [self reduce]; // Minimize number of VBO
  1115
+    for (GCodePath *path in segments)
  1116
+    {
  1117
+        [sl addLast:path];
  1118
+    }
  1119
+    [changeLock unlock];
1102 1120
     //long timeStart = DateTime.Now.Ticks;
1103 1121
     float *col;
1104 1122
     col = conf3d->filamentColor;
@@ -1111,7 +1129,6 @@ -(void)paint
1111 1129
     hotColor[1] = (float)col[1];
1112 1130
     hotColor[2] = (float)col[2];
1113 1131
     hotColor[3] = curColor[3] = col[3];
1114  
-    //           GL.Material(MaterialFace.FrontAndBack, MaterialParameter.AmbientAndDiffuse, new OpenTK.Graphics.Color4(col.R, col.G, col.B, 255));
1115 1132
     glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, defaultColor);
1116 1133
     glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION, conf3d->blackColor);
1117 1134
     glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, conf3d->specularColor);
@@ -1127,10 +1144,12 @@ -(void)paint
1127 1144
     lastFilWidth = w;
1128 1145
     lastFilDiameter = dfac;
1129 1146
     lastFilUseHeight = fixedH;
1130  
-    for (GCodePath *path in segments)
  1147
+    //   int cnt=0;
  1148
+    for (GCodePath *path in sl)
1131 1149
     {
1132 1150
         [self drawSegment:path];
1133 1151
     }
  1152
+    [sl release];
1134 1153
     // timeStart = DateTime.Now.Ticks - timeStart;
1135 1154
     //  double time = (double)timeStart * 0.1;
1136 1155
     // Main.conn.log("OpenGL paint time " + time.ToString("0.0", GCode.format) + " microseconds",false,4);
7  RepetierHost/RepetierHost/models/RHLogger.m
@@ -24,8 +24,8 @@
24 24
 
25 25
 @implementation RHLogEntry
26 26
 
27  
-@synthesize time;
28  
-@synthesize message;
  27
+@synthesize time = time;
  28
+@synthesize message = message;
29 29
 
30 30
 -(void)dealloc {
31 31
     [time release];
@@ -34,11 +34,12 @@ -(void)dealloc {
34 34
 }
35 35
 +(id)fromMessage:(NSString*)msg level:(RHLogType)aType response:(BOOL)isResp {
36 36
     RHLogEntry *e = [[RHLogEntry alloc] init];
37  
-    NSDate *date = [NSDate date];
  37
+    NSDate *date = [[NSDate alloc] init];
38 38
     e->level = aType;
39 39
     e->response = isResp;
40 40
     [e setMessage:msg];
41 41
     [e setTime:[logDateFormatter stringFromDate:date]];
  42
+    [date release];
42 43
     return [e autorelease];
43 44
 }
44 45
 -(BOOL)isACK {

0 notes on commit 2504d59

Please sign in to comment.
Something went wrong with that request. Please try again.