Gaaah! So close and yet so so far....

Ive streamlined the code, and it now includes MY version of accounting for FPS.
I couldnt get yours to work "the same" under different FPS rates.
[EDIT] I dont think this FPS-matching is correct. Ive got another idea in mind but I wont get to it till tonight...

But my TWO remaining issues are these.
1> Craps out if terrain is larger than 32x32. Is there some odd limitation on terrains?
(The vec_to_mesh seems to refuse to go higher than 1024 vertices.)

Issue fixed by using CONTACT structure.

2> I cannot sucessfully store a pointer to data-array[0] into the entities skill1.
Please check my code on this. Its not something Im familiar with....

Thanks guys....
Code:
#include <acknex.h>
#include <default.c>




#define	vertex_arrays	skill1		//vertex data arrays (var*)
#define	vertex_count	skill2		//number of vertices per array
#define	vertex_wide	skill3		//width of HMP in vertices
#define	vertex_high	skill4		//height of HMP in vertices
#define	viscosity	skill5		//"thickness" of the fluid.  0=Water -> 100=EngineOil

action fluid_action()
{
	if(!ent_status(my,2)||!ent_status(my,3))		return;		//not a terrain entity.
	var size_x=ent_status(my,2)+1, size_y=ent_status(my,3)+1;
	var x, y, f, tmp, ***data = malloc(sizeof(var)*2);
	for(f=0; f<2; f++)	
	{	data[f] = malloc(sizeof(var)*size_x);
		for(x=0; x<size_x; x++)	
		{	(data[f])[x] = malloc(sizeof(var)*size_y);
			for(y=0; y<size_y; y++)		
				((data[f])[x])[y]  = 0;
		}
	}
	my.vertex_arrays = (void*)(data[0])[0];
	my.vertex_count  = ent_status(my, 0);
	my.vertex_wide   = size_x;
	my.vertex_high   = size_y;
	my.viscosity	 = 0;
	while(me)
	{	
		f = !f;
		for(y=1; y<(size_y-1); y++)   for(x=1; x<(size_x-1); x++)   
		{	
			tmp  = ((data[!f])[x-1])[y] + ((data[!f])[x+1])[y] + ((data[!f])[x])[y-1] + ((data[!f])[x])[y+1];
			((data[f])[x])[y]  = (tmp / 2 - ((data[f])[x])[y]) * 0.95;
			CONTACT* c = ent_getvertex(my,NULL,(y*size_x)+x+1);    
			c.v.y = ((data[f])[x])[y];
			ent_setvertex(my,c,(y*size_x)+x+1);
		}
		if(key_1)	((data[0])[2])[size_y/2] += 5;		//TEST POKE - debug only
		wait(-(25+my.viscosity)/1000);
	}	
	//cleanup
	for(x=0; x<size_x; x++)	{  free((data[0])[x]);	free((data[1])[x]);  }
	free(data[0]);		free(data[1]);	 	free(data);	 
}



ENTITY* waterent;

function main()
{
	video_mode = 10;
	video_screen = 1;
	level_load("");
	vec_set(camera.x,   vector(0,50,50));
	vec_set(camera.pan, vector(270,-45,0));
	//
	waterent = ent_create("waterent32.hmp", nullvector, fluid_action);
	//
	while(1)
	{
		if(key_cuu)
		{
			beep();
			((var*)waterent.vertex_arrays)[110]	+= 15;
			while(key_cuu)	wait(1);
		}
		wait(1);
	}
	//cleanup
	for(x=0; x<size_x; x++)	{  free((data[0])[x]);   free((data[1])[x]);  }
	free(data[0]);		free(data[0]);	 	free(data);	 
}
//



Last edited by EvilSOB; 07/07/09 21:15.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial