node replicating [solved]

hi, i have a other problem, i want to do a new node where a other node get replicate to.

but im getting a error: !is_empty()
while looping over it.

sorry im new to c++ :frowning: (im working with c++ just for couple of days)

float overLAP = .02;
					
					for (int ri = 0;ri < 100; ri++) {
						int cc = 0;
						
						
						for (int ii =0;ii < 100; ii++) {
							NodePath partX[100];
							if ((part[ii].get_x()>bigCELL[25].get_x()+(part[ii].get_x()/relX/5)-overLAP)&&(part[ii].get_x()<bigCELL[25].get_x()+.2+(part[ii].get_x()/relX/5)+overLAP)&&(part[ii].get_z()>bigCELL[25].get_z()-overLAP)&&(part[ii].get_z()<bigCELL[25].get_z()+.2+overLAP)) {
														// doing a new particle Node
								partX[cc] = part[ii];
								for (int ci = 0; ci<cc;ci++) {
									partX[ci].set_color(1,1,1,1); // there is the problem!
								}
								cc+=1;	
							}
							else {
								part[ii].set_color(1,0,0,1);
							}
							
							
						}
					}

shame on me lol
i have fixed it, after i posted here lol!!

the node init, was in the wrong loop!!!

float overLAP = .02; 
                
               for (int ri = 0;ri < 100; ri++) { 
                  int cc = 0; 
                   
                  NodePath partX[100]; 
                  for (int ii =0;ii < 100; ii++) { 
                      
                     if ((part[ii].get_x()>bigCELL[25].get_x()+(part[ii].get_x()/relX/5)-overLAP)&&(part[ii].get_x()<bigCELL[25].get_x()+.2+(part[ii].get_x()/relX/5)+overLAP)&&(part[ii].get_z()>bigCELL[25].get_z()-overLAP)&&(part[ii].get_z()<bigCELL[25].get_z()+.2+overLAP)) { 
                                          // doing a new particle Node 
                        partX[cc] = part[ii]; 
                       

                        
                        cc+=1;    
                     } 
                     else { 
                        part[ii].set_color(1,0,0,1); 
                     } 
 for (int ci = 0; ci<cc;ci++) { 
                           partX[ci].set_color(1,1,1,1);
}
                      
                      
                  } 
               }

thats my raster based, self collision script, it works nice. but i need to improve some parts.

for (int ri = 0;ri < 100; ri++) {
						int cc = 0;
						// loops over particles
						// X needs to be relative to the win size (x/relX/5)
						// add a overlapping for a better result
						NodePath partX[400];
						bigCELL[ri].hide();
						for (int ii =0;ii < count; ii++) {
						

							if ((part[ii].get_x()>bigCELL[ri].get_x()+(part[ii].get_x()/relX/5)-overLAP)&&(part[ii].get_x()<bigCELL[ri].get_x()+.2+(part[ii].get_x()/relX/5)+overLAP)&&(part[ii].get_z()>bigCELL[ri].get_z()-overLAP)&&(part[ii].get_z()<bigCELL[ri].get_z()+.2+overLAP)) {
	
								// doing a new particle Node
								partX[cc] = part[ii];
								LPoint3f pos1 = partX[cc].get_pos();

							//	bigCELL[ri].show();

								for (int ci = 0; ci<cc;ci++) {
									if (partX[cc] != partX[ci]){
										LPoint3f pos2 = partX[ci].get_pos();
										LVecBase3f distance = pos1-pos2;
										float dis (distance.length());
										if (dis < .08) {
											float base = partX[cc].get_x() - partX[ci].get_x();
											partX[ci].set_x(partX[ci].get_x()-base/50.5*(dis*50));
											float high = partX[cc].get_z() - partX[ci].get_z();
											partX[ci].set_z(partX[ci].get_z()-high/50.5*(dis*50));
										}

									}

								}

								cc+=1;	
							}
							
								
							

						}

so i changed some parts again, it works much smoother with a velociy.

[code]
float overLAP = .01;
int cc;
for (int ri = 0;ri < 100; ri++) {
cc = 0;
bigCELL[ri].hide();

	for (int ii =0;ii < partCOUNT; ii++) {
		if ((particles[ii].get_x()*relX>bigCELL[ri].get_x())&&(particles[ii].get_x()*1.5<bigCELL[ri].get_x()+.2)&&(particles[ii].get_z()>bigCELL[ri].get_z()-overLAP)&&(particles[ii].get_z()<bigCELL[ri].get_z()+.2+overLAP)) {
			partX[cc] = particles[ii];
			partXid[cc] = ii;
			bigCELL[ri].show();
			cc+=1;					
		}	
	}
	
	if (cc > 0) {
		for (int cii = 0; cii<cc;cii++) {
			for (int ci =0; ci<cc;ci++) {
				if (partX[cii].get_pos() != partX[ci].get_pos()){
					LVecBase3f distance = (partX[ci].get_pos()-partX[cii].get_pos());
					float dis (distance.length());
					
					if (dis < .025) {
					//	partX[ci].set_color(colorRED[ri],colorGREEN[ri],colorBLUE[ri],1);
						float base = partX[cii].get_x() - partX[ci].get_x();
						float high = partX[cii].get_z() - partX[ci].get_z();		
						partVELOx[partXid[cii]] += base/(dis*400);
						partVELOy[partXid[cii]] += high/(dis*400);
					}
				}
			}
		}
	}
}code]