/** * Search the nearest Neighbor of the scalar array query. * * \param[in] query The query array * \param[out] indice The indice of array in the dataset that * have been computed as the nearest array. * \param[out] distance The distance between the two arrays. * * \return True if success. */ bool SearchNeighbour ( const Scalar * query, int * indice, DistanceType * distance ) override { if (memMapping.get() != nullptr) { //matrix representation of the input data; Eigen::Map<BaseMat> mat_query((Scalar*)query, 1, (*memMapping).cols() ); Metric metric; vector<DistanceType> vec_dist((*memMapping).rows(), 0.0); for (int i = 0; i < (*memMapping).rows(); ++i) { // Compute Distance Metric vec_dist[i] = metric( (Scalar*)query, (*memMapping).row(i).data(), (*memMapping).cols() ); } if (!vec_dist.empty()) { // Find the minimum distance : typename vector<DistanceType>::const_iterator min_iter = min_element( vec_dist.begin(), vec_dist.end()); *indice =std::distance( typename vector<DistanceType>::const_iterator(vec_dist.begin()), min_iter); *distance = static_cast<DistanceType>(*min_iter); } return true; } else { return false; } }
static void compute_id_range(struct efp *efp, size_t from, size_t to, void *data) { double conv = 0.0; vec_t *id_new, *id_conj_new; id_new = ((struct id_work_data *)data)->id_new; id_conj_new = ((struct id_work_data *)data)->id_conj_new; #ifdef _OPENMP #pragma omp parallel for schedule(dynamic) reduction(+:conv) #endif for (size_t i = from; i < to; i++) { struct frag *frag = efp->frags + i; for (size_t j = 0; j < frag->n_polarizable_pts; j++) { struct polarizable_pt *pt = frag->polarizable_pts + j; size_t idx = frag->polarizable_offset + j; vec_t field, field_conj; /* electric field from other induced dipoles */ get_induced_dipole_field(efp, i, pt, &field, &field_conj); /* add field that doesn't change during scf */ field.x += pt->elec_field.x + pt->elec_field_wf.x; field.y += pt->elec_field.y + pt->elec_field_wf.y; field.z += pt->elec_field.z + pt->elec_field_wf.z; field_conj.x += pt->elec_field.x + pt->elec_field_wf.x; field_conj.y += pt->elec_field.y + pt->elec_field_wf.y; field_conj.z += pt->elec_field.z + pt->elec_field_wf.z; id_new[idx] = mat_vec(&pt->tensor, &field); id_conj_new[idx] = mat_trans_vec(&pt->tensor, &field_conj); conv += vec_dist(&id_new[idx], &efp->indip[idx]); conv += vec_dist(&id_conj_new[idx], &efp->indipconj[idx]); } } ((struct id_work_data *)data)->conv += conv; }
//проверка расстояния bool VisiblePatchArray::DistAppropriate( const dataPatch &patch ) { //патч такого размера надо еще разбивать на потомков //if ( patch.m_iSize > 32768 ) // return false; ////////////////////////////////////////////////////////////////////////// std::vector< dataPatch > vTemp; dataPatch downPatch; downPatch.m_iX = patch.m_iX; downPatch.m_iY = patch.m_iY; downPatch.m_iSize = patch.m_iSize / 2; vTemp.push_back( downPatch ); //1 патч downPatch.m_iX = patch.m_iX + downPatch.m_iSize; vTemp.push_back( downPatch ); //2 патч downPatch.m_iY = patch.m_iY + downPatch.m_iSize; vTemp.push_back( downPatch ); //3 патч downPatch.m_iX = patch.m_iX; vTemp.push_back( downPatch ); //4 патч ////////////////////////////////////////////////////////////////////////// for ( int i = 0 ; i < 4 ; ++i ) { osg::Vec3 vec_dist( vTemp[ i ].m_iX + vTemp[ i ].m_iSize * 0.5 - m_Pos.x() , vTemp[ i ].m_iY + vTemp[ i ].m_iSize * 0.5 - m_Pos.y(), -m_Pos.z() ); double dist = sqrt( vec_dist.x() * vec_dist.x() + vec_dist.y() * vec_dist.y() + vec_dist.z() * vec_dist.z() ); double radius = vTemp[ i ].m_iSize * 2.0; if ( dist < radius ) { if ( patch.m_iSize == 512 ) { //это последний уровень, записать в список патчей на отображение m_vVisible.push_back( patch ); return true; } else { return false; } } } m_vVisible.push_back( patch ); return true; }
vprop_t vprop_animate(vprop_t vp, float dt){ vec_t s; if (!(vp.speed == 0.0 || vec_equal(vp.val,vp.target))){ s = vec_scale(vec_normalize(vec_diff(vp.val,vp.target)),vp.speed); if(vec_dist(vp.val,vp.target) < vec_len(s)){ vp.val = vp.target; }else{ vp.val = vec_add(vp.val,s); } } return vp; }
void item_loop() { my->emask |= ENABLE_TRIGGER; my->trigger_range = 30; set (me, PASSABLE); my->pan = random(360); var vZ = my->z; var vOffset = random(500); var vParticles = 0; if (c_trace(&my->x, vector(my->x, my->y, my->z - 1000), IGNORE_ME | IGNORE_PASSABLE) > 0) { my->z = hit->z + ITEM_HEIGHT; } while(player == NULL) { wait(1); } while(!is(me, is_collected)) { if (dayOrNight == DAY && vec_dist(&player->x, &my->x) < 1000) { vParticles += time_step; while (vParticles > 1) { effect(item_particle, 1, &my->x, nullvector); vParticles -= 1; } my->z = vZ + 10 * sinv(total_ticks * 20 + vOffset); my->pan -= 5 * time_step; reset(my, INVISIBLE); my->emask |= ENABLE_TRIGGER; } else { set(my, INVISIBLE); my->emask &= ~ENABLE_TRIGGER; } wait(1); } item_fade(); }
void set_destination(double *v) { int i; double dif[MAX_DIM]; vec_copy(origin, position); vec_copy(destination, v); tim = 0.0; delta_t = feedrate_begin; dist = vec_dist(position, v); if(dist == 0.0) { vec_clear(incvec); for(i = 0; i < MAX_DIM; i++) amp[i] = amplitude_dc; return; } vec_diff(dif, v, origin); for(i = 0; i < MAX_DIM; i++) incvec[i] = dif[i] / dist; calc_amplitude(); }
// Stone rain action ebHandStone () { set(me, PASSABLE); var randomFallSpeed = random(20); while(my.z > -100) { my.z -=(20+randomFallSpeed) * time_step; my.pan +=randomFallSpeed * time_step; my.tilt +=randomFallSpeed * time_step; my.roll +=randomFallSpeed * time_step; // Give player 2 seconds to recover from last hit if (g_playerJustBeenHit == 0) { // Stone hits player? if (vec_dist(player.x, my.x) < 30) { // Play sounds if (!snd_playing(vPlayerSndHandle)) vPlayerSndHandle = snd_play(g_sndHitByStone, 100, 0); snd_play(g_sndStoneImpact, 100, 0); player.PL_HEALTH -=1; ent_remove(me); g_playerJustBeenHit = 2; // Wait 2 seconds while(g_playerJustBeenHit > 0) { g_playerJustBeenHit -=1; wait(-1); } return; } } wait(1); } ent_remove(me); }
// 再急勾配法(サーセンwww)による学習 int SVM::learning(void) { int iteration; // 学習繰り返しカウント float* diff_alpha; // 双対問題の勾配値 float* pre_diff_alpha; // 双対問題の前回の勾配値(慣性項に用いる) float* pre_alpha; // 前回の双対係数ベクトル(収束判定に用いる) register float diff_sum; // 勾配計算用の小計 register float kernel_val; // カーネル関数とC2を含めた項 //float plus_sum, minus_sum; // 正例と負例の係数和 // 配列(ベクトル)のアロケート diff_alpha = new float[n_sample]; pre_diff_alpha = new float[n_sample]; pre_alpha = new float[n_sample]; status = SVM_NOT_LEARN; // 学習を未完了に iteration = 0; // 繰り返し回数を初期化 // 双対係数の初期化.乱択 for (int i = 0; i < n_sample; i++ ) { // 欠損データの係数は0にして使用しない if ( label[i] == 0 ) { alpha[i] = 0; continue; } alpha[i] = uniform_rand(1.0) + 1.0; } // 学習ループ while ( iteration < maxIteration ) { printf("ite: %d diff_norm : %f alpha_dist : %f \r\n", iteration, two_norm(diff_alpha, n_sample), vec_dist(alpha, pre_alpha, n_sample)); // 前回の更新値の記録 memcpy(pre_alpha, alpha, sizeof(float) * n_sample); if ( iteration >= 1 ) { memcpy(pre_diff_alpha, diff_alpha, sizeof(float) * n_sample); } else { // 初回は0埋めで初期化 memset(diff_alpha, 0, sizeof(float) * n_sample); memset(pre_diff_alpha, 0, sizeof(float) * n_sample); } // 勾配値の計算 for (int i=0; i < n_sample; i++) { diff_sum = 0; for (int j=0; j < n_sample;j++) { // C2を踏まえたカーネル関数値 kernel_val = kernel_function(&(MATRIX_AT(sample,dim_signal,i,0)), &(MATRIX_AT(sample,dim_signal,j,0)), dim_signal); // kernel_val = MATRIX_AT(grammat,n_sample,i,j); // via Gram matrix if (i == j) { kernel_val += (1/C2); } diff_sum += alpha[j] * label[j] * kernel_val; } diff_sum *= label[i]; diff_alpha[i] = 1 - diff_sum; } // 双対変数の更新 for (int i=0; i < n_sample; i++) { if ( label[i] == 0 ) { continue; } //printf("alpha[%d] : %f -> ", i, alpha[i]); alpha[i] = pre_alpha[i] + eta * diff_alpha[i] + learn_alpha * pre_diff_alpha[i]; //printf("%f \dim_signal", alpha[i]); // 非数/無限チェック if ( isnan(alpha[i]) || isinf(alpha[i]) ) { fprintf(stderr, "Detected NaN or Inf Dual-Coffience : pre_alhpa[%d]=%f -> alpha[%d]=%f", i, pre_alpha[i], i, alpha[i]); return SVM_DETECT_BAD_VAL; } } // 係数の制約条件1:正例と負例の双対係数和を等しくする. // 手法:標本平均に寄せる float norm_sum = 0; for (int i = 0; i < n_sample; i++ ) { norm_sum += (label[i] * alpha[i]); } norm_sum /= n_sample; for (int i = 0; i < n_sample; i++ ) { if ( label[i] == 0 ) { continue; } alpha[i] -= (norm_sum / label[i]); } // 係数の制約条件2:双対係数は非負 for (int i = 0; i < n_sample; i++ ) { if ( alpha[i] < 0 ) { alpha[i] = 0; } else if ( alpha[i] > C1 ) { // C1を踏まえると,係数の上限はC1となる. alpha[i] = C1; } } // 収束判定 : 凸計画問題なので,収束時は大域最適が // 保証されている. if ( (vec_dist(alpha, pre_alpha, n_sample) < epsilon) || (two_norm(diff_alpha, n_sample) < epsilon) ) { // 学習の正常完了 status = SVM_LEARN_SUCCESS; break; } // 学習繰り返し回数のインクリメント iteration++; } if (iteration >= maxIteration) { fprintf(stderr, "Learning is not convergenced. (iteration count > maxIteration) \r\n"); status = SVM_NOT_CONVERGENCED; } else if ( status != SVM_LEARN_SUCCESS ) { status = SVM_NOT_LEARN; } // 領域開放 delete [] diff_alpha; delete [] pre_diff_alpha; delete [] pre_alpha; return status; }
// uses: id, speed, idletime action moving_platform() { set(my, is_platform); my->ptr_start = NULL; my->ptr_end = NULL; if (my->idletime == 0) my->idletime = 0.001; wait (1); for(you = ent_next(NULL); (you != NULL) && (my->ptr_end == NULL); you = ent_next(you)) { if ((your->id == my->id) && (my->id > 0) && is(you, is_marker)) { if (my->ptr_start == NULL) { my->ptr_start = handle(you); } else if (my->ptr_end == NULL) { my->ptr_end = handle(you); } else { //do nothing } } } if ((my->ptr_end == NULL) || (my->id <= 0)) { printf("incorrect platform marker for id %d", (int)my->id); return; } //platform start point VECTOR vecSpeed; VECTOR vecTemp; ENTITY *ent1, *ent2, *entTarget, *entCur, *entTemp; ent1 = ptr_for_handle(my->ptr_start); ent2 = ptr_for_handle(my->ptr_end); //directional speed vec_set(&vecSpeed, &ent2->x); vec_sub(&vecSpeed, &ent1->x); vec_normalize(&vecSpeed, my->speed); if (vec_dist(&ent1->x, &my->x) < vec_dist(&ent2->x, &my->x)) { vec_set(&my->x, &ent1->x); entTarget = ent2; entCur = ent1; } else { vec_set(&my->x, &ent2->x); entTarget = ent1; entCur = ent2; vec_scale(&vecSpeed, -1); } //entity loop while(1) { vec_set(vecTemp, vecSpeed); vec_scale(vecTemp, time_step); vec_set(&my->absspeed_x, &vecTemp); you = player; c_move(me, nullvector, &vecTemp, IGNORE_MODELS | IGNORE_SPRITES | IGNORE_YOU | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_MAPS); if(vec_dist(&entTarget->x, &my->x) < 20) { wait (1); vec_set(&my->absspeed_x, nullvector); wait(-(my->idletime)); vec_scale(&vecSpeed, -1); entTemp = entCur; entCur = entTarget; entTarget = entTemp; } wait (1); } }
// uses: id, speed action rotating_platform() { set(my, is_platform); my->ptr_start = NULL; my->ptr_end = NULL; wait (1); for(you = ent_next(NULL); (you != NULL) && (my->ptr_end == NULL); you = ent_next(you)) { if ((your->id == my->id) && (my->id > 0) && is(you, is_marker)) { if (my->ptr_start == NULL) { my->ptr_start = handle(you); } else if (my->ptr_end == NULL) { my->ptr_end = handle(you); } else { //do nothing } } } if ((my->ptr_end == NULL) || (my->id <= 0)) { printf("incorrect platform marker for id %d", (int)my->id); return; } //platform start point VECTOR vecSpeed, vecTemp; ENTITY *ent1, *ent2, *entCenter; var vRadius; var vAngle; ent1 = ptr_for_handle(my->ptr_start); ent2 = ptr_for_handle(my->ptr_end); if (vec_dist(&ent1->x, &my->x) < vec_dist(&ent2->x, &my->x)) { vec_set(&my->x, &ent1->x); entCenter = ent2; ent2->y = ent1->y; } else { vec_set(&my->x, &ent2->x); entCenter = ent1; ent1->y = ent2->y; } //directional speed vec_set(&vecSpeed, nullvector); vRadius = vec_dist(&ent1->x, &ent2->x); //entity loop while(1) { vAngle += time_step * my->speed; vAngle = ang(vAngle); vec_set(&vecSpeed, nullvector); vecSpeed.x = vRadius; vec_rotate(&vecSpeed, vector(0, vAngle, 0)); vec_add(&vecSpeed, &entCenter->x); vec_sub(&vecSpeed, &my->x); vec_scale(&vecSpeed, time_step); vec_set(&my->absspeed_x, &vecSpeed); you = player; c_move(me, nullvector, &vecSpeed, IGNORE_MODELS | IGNORE_SPRITES | IGNORE_YOU | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_MAPS); wait (1); } }
/* * Reference * * Simone Melchionna, Giovanni Ciccotti, Brad Lee Holian * * Hoover NPT dynamics for systems varying in shape and size * * Mol. Phys. 78, 533 (1993) */ static void update_step_npt(struct md *md) { struct npt_data *data = (struct npt_data *)md->data; double dt = cfg_get_double(md->state->cfg, "time_step"); double t_tau = cfg_get_double(md->state->cfg, "thermostat_tau"); double t_target = cfg_get_double(md->state->cfg, "temperature"); double p_tau = cfg_get_double(md->state->cfg, "barostat_tau"); double p_target = cfg_get_double(md->state->cfg, "pressure"); double t_tau2 = t_tau * t_tau; double p_tau2 = p_tau * p_tau; double kbt = BOLTZMANN * t_target; double t0 = get_temperature(md); double p0 = get_pressure(md); double v0 = get_volume(md); for (size_t i = 0; i < md->n_bodies; i++) { struct body *body = md->bodies + i; body->vel.x += 0.5 * dt * (body->force.x / body->mass - body->vel.x * (data->chi + data->eta)); body->vel.y += 0.5 * dt * (body->force.y / body->mass - body->vel.y * (data->chi + data->eta)); body->vel.z += 0.5 * dt * (body->force.z / body->mass - body->vel.z * (data->chi + data->eta)); body->angmom.x += 0.5 * dt * (body->torque.x - body->angmom.x * data->chi); body->angmom.y += 0.5 * dt * (body->torque.y - body->angmom.y * data->chi); body->angmom.z += 0.5 * dt * (body->torque.z - body->angmom.z * data->chi); rotate_body(body, dt); } data->chi += 0.5 * dt * (t0 / t_target - 1.0) / t_tau2; data->chi_dt += 0.5 * dt * data->chi; data->eta += 0.5 * dt * v0 * (p0 - p_target) / md->n_bodies / kbt / p_tau2; vec_t com = get_system_com(md); vec_t pos_init[md->n_bodies]; for (size_t i = 0; i < md->n_bodies; i++) pos_init[i] = md->bodies[i].pos; for (size_t iter = 1; iter <= MAX_ITER; iter++) { bool done = true; for (size_t i = 0; i < md->n_bodies; i++) { struct body *body = md->bodies + i; vec_t pos = wrap(md, &body->pos); vec_t v = { data->eta * (pos.x - com.x), data->eta * (pos.y - com.y), data->eta * (pos.z - com.z) }; vec_t new_pos = { pos_init[i].x + dt * (body->vel.x + v.x), pos_init[i].y + dt * (body->vel.y + v.y), pos_init[i].z + dt * (body->vel.z + v.z) }; done = done && vec_dist(&body->pos, &new_pos) < EPSILON; body->pos = new_pos; } if (done) break; if (iter == MAX_ITER) msg("WARNING: NPT UPDATE DID NOT CONVERGE\n\n"); } vec_scale(&md->box, exp(dt * data->eta)); check_fail(efp_set_periodic_box(md->state->efp, md->box.x, md->box.y, md->box.z)); compute_forces(md); double chi_init = data->chi, eta_init = data->eta; vec_t angmom_init[md->n_bodies], vel_init[md->n_bodies]; for (size_t i = 0; i < md->n_bodies; i++) { angmom_init[i] = md->bodies[i].angmom; vel_init[i] = md->bodies[i].vel; } for (size_t iter = 1; iter <= MAX_ITER; iter++) { double chi_prev = data->chi; double eta_prev = data->eta; double t_cur = get_temperature(md); double p_cur = get_pressure(md); double v_cur = get_volume(md); data->chi = chi_init + 0.5 * dt * (t_cur / t_target - 1.0) / t_tau2; data->eta = eta_init + 0.5 * dt * v_cur * (p_cur - p_target) / md->n_bodies / kbt / p_tau2; for (size_t i = 0; i < md->n_bodies; i++) { struct body *body = md->bodies + i; body->vel.x = vel_init[i].x + 0.5 * dt * (body->force.x / body->mass - vel_init[i].x * (data->chi + data->eta)); body->vel.y = vel_init[i].y + 0.5 * dt * (body->force.y / body->mass - vel_init[i].y * (data->chi + data->eta)); body->vel.z = vel_init[i].z + 0.5 * dt * (body->force.z / body->mass - vel_init[i].z * (data->chi + data->eta)); body->angmom.x = angmom_init[i].x + 0.5 * dt * (body->torque.x - angmom_init[i].x * data->chi); body->angmom.y = angmom_init[i].y + 0.5 * dt * (body->torque.y - angmom_init[i].y * data->chi); body->angmom.z = angmom_init[i].z + 0.5 * dt * (body->torque.z - angmom_init[i].z * data->chi); } if (fabs(data->chi - chi_prev) < EPSILON && fabs(data->eta - eta_prev) < EPSILON) break; if (iter == MAX_ITER) msg("WARNING: NPT UPDATE DID NOT CONVERGE\n\n"); } data->chi_dt += 0.5 * dt * data->chi; }
void net_entsync(ENTITY *ent) { ent.event = net_entsync_event; ent.emask |= ENABLE_RECEIVE; ent.smask = NOSEND_ALPHA | NOSEND_AMBIENT | NOSEND_ANGLES | NOSEND_ATTACH | NOSEND_COLOR | NOSEND_FLAGS | NOSEND_FRAME | NOSEND_LIGHT | NOSEND_ORIGIN | NOSEND_SCALE | NOSEND_SKIN | NOSEND_SOUND; // Wait for network handle while(ent.client_id < 0) wait(1); ent.NET_SKILL_LERPSPEED = net_ent_default_lerpspeed; proc_mode = PROC_GLOBAL | PROC_LATE; if(ent.client_id == dplay_id) { // Controller var update = net_ent_sendrate; while(handle(ent) != NULL) { // Send entity updates update -= time_step; if(update <= 0) { // Send position if distance since last update greater the minimum send distance if(vec_dist(ent.x, ent.NET_SKILL_POS_X) > net_ent_mindist) { vec_set(ent.NET_SKILL_POS_X, ent.x); if(net_ent_flags & NET_ENT_UNRELIABLE) send_skill(ent.NET_SKILL_POS_X, SEND_VEC | SEND_ALL | SEND_UNRELIABLE); else send_skill(ent.NET_SKILL_POS_X, SEND_VEC | SEND_ALL); } if(vec_dist(ent.pan, ent.NET_SKILL_ANG_PAN) > net_ent_mindiff) { vec_set(ent.NET_SKILL_ANG_PAN, ent.pan); if(net_ent_flags & NET_ENT_UNRELIABLE) send_skill(ent.NET_SKILL_ANG_PAN, SEND_VEC | SEND_ALL | SEND_UNRELIABLE); else send_skill(ent.NET_SKILL_ANG_PAN, SEND_VEC | SEND_ALL); } update = net_ent_sendrate; } wait(1); } } else { // Receiver while(handle(ent) != NULL) { if(net_ent_lerpfactor > 0) { // Lerping vec_lerp(ent.x, ent.x, ent.NET_SKILL_POS_X, net_ent_lerpfactor); ang_lerp(ent.pan, ent.pan, ent.NET_SKILL_ANG_PAN, net_ent_lerpfactor); } else { // Linear movement VECTOR dir; vec_diff(dir, ent.NET_SKILL_POS_X, ent.x); var dist = vec_length(dir); if(dist > 0.5 * net_ent_mindist) { vec_normalize(dir, minv(ent.NET_SKILL_LERPSPEED * time_step, dist)); vec_add(ent.x, dir); } vec_set(ent.pan, ent.NET_SKILL_ANG_PAN); } wait(1); } } }
void sc_light_checkSpotFrustum() { wait(3); ENTITY* inLight = my; //ent_create(CUBE_MDL, inLight.x, NULL); //ent_create(CUBE_MDL, nullvector, NULL); SC_OBJECT* ObjData = (SC_OBJECT*)(inLight.SC_SKILL); SC_SCREEN* screen; //HAVOC : CHANGE THIS (sc_screen_default) while(sc_screen_default == NULL) wait(1); SC_SCREEN* screen = sc_screen_default; VIEW* playerView = screen.views.main; // while(inLight) { #ifdef SC_USEPVS //check if light has been clipped by engine or main view is far away from light if( (inLight.eflags&CLIPPED) || abs(vec_dist(playerView.x, inLight.x)) > ObjData.light.clipRange + ObjData.light.range ) { reset(ObjData.light.view, SHOW); //ObjData.myLightMtl = sc_lpp_mtlS; } else { set(ObjData.light.view,SHOW); /* //lightview intersects with camera? OBB-OBB check if( sc_physics_intersectViewView(playerView, ObjData.light.view) ) { set(ObjData.light.view, SHOW); // //lightview intersects with camera? cone-sphere check // if( sc_physics_intersectViewSphere(screen.views.main, inLight.x, ObjData.light.range) ) // { // //sc_light_setColor(inLight, vector(255, 0,0) ); // reset(ObjData.light.view, SHOW); // } // else // { // //sc_light_setColor(inLight, vector(0, 255,0) ); // set(ObjData.light.view, SHOW); // } } else { //sc_light_setColor(inLight, vector(255, 0,0) ); reset(ObjData.light.view, SHOW); } */ } #else //check if light has been clipped by engine or playerView is far away from light if( (inLight.eflags&CLIPPED) || abs(vec_dist(playerView.x, inLight.x)) > ObjData.light.clipRange + ObjData.light.range ) { reset(ObjData.light.view, SHOW); } else { //lightview intersects with camera? OBB-OBB check | or main view is far away from light if( sc_physics_intersectViewView(playerView, ObjData.light.view) && vec_dist(playerView.x, inLight.x) < ObjData.light.clipRange + ObjData.light.range ) { set(ObjData.light.view, SHOW); /* //lightview intersects with camera? cone-sphere check if( sc_physics_intersectViewSphere(screen.views.main, inLight.x, ObjData.light.range) ) { //sc_light_setColor(inLight, vector(255, 0,0) ); reset(ObjData.light.view, SHOW); } else { //sc_light_setColor(inLight, vector(0, 255,0) ); set(ObjData.light.view, SHOW); } */ } else { //sc_light_setColor(inLight, vector(255, 0,0) ); reset(ObjData.light.view, SHOW); } } #endif wait(10); } }