本文整理汇总了C++中v3f::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ v3f::normalize方法的具体用法?C++ v3f::normalize怎么用?C++ v3f::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v3f
的用法示例。
在下文中一共展示了v3f::normalize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getVisibleBrightness
static bool getVisibleBrightness(Map *map, v3f p0, v3f dir, float step,
float step_multiplier, float start_distance, float end_distance,
INodeDefManager *ndef, u32 daylight_factor, float sunlight_min_d,
int *result, bool *sunlight_seen)
{
int brightness_sum = 0;
int brightness_count = 0;
float distance = start_distance;
dir.normalize();
v3f pf = p0;
pf += dir * distance;
int noncount = 0;
bool nonlight_seen = false;
bool allow_allowing_non_sunlight_propagates = false;
bool allow_non_sunlight_propagates = false;
// Check content nearly at camera position
{
v3s16 p = floatToInt(p0 /*+ dir * 3*BS*/, BS);
MapNode n = map->getNodeNoEx(p);
if(ndef->get(n).param_type == CPT_LIGHT &&
!ndef->get(n).sunlight_propagates)
allow_allowing_non_sunlight_propagates = true;
}
// If would start at CONTENT_IGNORE, start closer
{
v3s16 p = floatToInt(pf, BS);
MapNode n = map->getNodeNoEx(p);
if(n.getContent() == CONTENT_IGNORE){
float newd = 2*BS;
pf = p0 + dir * 2*newd;
distance = newd;
sunlight_min_d = 0;
}
}
for(int i=0; distance < end_distance; i++){
pf += dir * step;
distance += step;
step *= step_multiplier;
v3s16 p = floatToInt(pf, BS);
MapNode n = map->getNodeNoEx(p);
if(allow_allowing_non_sunlight_propagates && i == 0 &&
ndef->get(n).param_type == CPT_LIGHT &&
!ndef->get(n).sunlight_propagates){
allow_non_sunlight_propagates = true;
}
if(ndef->get(n).param_type != CPT_LIGHT ||
(!ndef->get(n).sunlight_propagates &&
!allow_non_sunlight_propagates)){
nonlight_seen = true;
noncount++;
if(noncount >= 4)
break;
continue;
}
if(distance >= sunlight_min_d && *sunlight_seen == false
&& nonlight_seen == false)
if(n.getLight(LIGHTBANK_DAY, ndef) == LIGHT_SUN)
*sunlight_seen = true;
noncount = 0;
brightness_sum += decode_light(n.getLightBlend(daylight_factor, ndef));
brightness_count++;
}
*result = 0;
if(brightness_count == 0)
return false;
*result = brightness_sum / brightness_count;
/*std::cerr<<"Sampled "<<brightness_count<<" points; result="
<<(*result)<<std::endl;*/
return true;
}