GroupSteeringAccumulator class
Пакет: com.hypixel.hytale.server.npc.movement
Файл: com/hypixel/hytale/server/npc/movement/GroupSteeringAccumulator.java
Поля (37)
| Модификаторы | Тип | Имя |
|---|---|---|
|
double |
var1 |
|
Vector3d |
var10 |
|
double |
var11 |
|
Velocity |
var11 |
|
Vector3d |
var12 |
|
double |
var13 |
|
double |
var13 |
|
|
var13 |
|
Velocity |
var15 |
|
double |
var15 |
|
|
var15 |
|
Vector3d |
var16 |
|
TransformComponent |
var17 |
|
double |
var17 |
|
|
var17 |
|
Vector3d |
var18 |
|
double |
var19 |
|
|
var19 |
|
|
var19 |
|
|
var19 |
|
double |
var21 |
|
|
var21 |
|
|
var21 |
|
double |
var23 |
|
HeadRotation |
var3 |
|
double |
var3 |
|
double |
var30 |
|
double |
var31 |
|
|
var31 |
|
|
var31 |
|
Rotation3f |
var4 |
|
TransformComponent |
var5 |
|
double |
var5 |
|
Vector3d |
var6 |
|
double |
var7 |
|
double |
var9 |
|
TransformComponent |
var9 |
Методы (14)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
void |
beginvoid begin(double var1, double var3, double var5, double var7, double var9, double var11) |
public |
void |
beginvoid begin(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) |
public |
void |
endvoid end() |
public |
int |
getCountint getCount() |
|
|
if if(!this.normalizeDistances) |
|
|
if if(var19 < 1.0E-12) |
|
|
if if(this.count > 0) |
|
|
if if(this.normalizeDistances) |
public |
void |
processEntityvoid processEntity(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) |
public |
void |
processEntityvoid processEntity(@Nonnull Ref<EntityStore> var1, double var2, double var4, double var6, @Nonnull ComponentAccessor<EntityStore> var8) |
public |
void |
setComponentSelectorvoid setComponentSelector(Vector3d var1) |
public |
void |
setMaxRangevoid setMaxRange(double var1) |
public |
void |
setNormalizeDistancesvoid setNormalizeDistances(boolean var1) |
public |
void |
setViewConeHalfAngleCosinevoid setViewConeHalfAngleCosine(float var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.movement;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.random.RandomExtra;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.physics.component.Velocity;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.util.NPCPhysicsMath;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">public class GroupSteeringAccumulator {
@Nonnull
class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, TransformComponent> TRANSFORM_COMPONENT_TYPE = TransformComponent.getComponentType();
class="kw">private class="kw">final Vector3d sumOfVelocities = new Vector3d();
class="kw">private class="kw">final Vector3d sumOfDistances = new Vector3d();
class="kw">private class="kw">final Vector3d sumOfPositions = new Vector3d();
class="kw">private class="kw">final Vector3d temp = new Vector3d();
class="kw">private int count;
class="kw">private double x;
class="kw">private double y;
class="kw">private double z;
class="kw">private double xViewDirection;
class="kw">private double yViewDirection;
class="kw">private double zViewDirection;
class="kw">private class="kw">final Vector3d componentSelector = new Vector3d(Vector3dUtil.ALL_ONES);
class="kw">private double maxRangeSquared = Double.MAX_VALUE;
class="kw">private double maxDistance = Double.MAX_VALUE;
class="kw">private float collisionViewHalfAngleCosine = 1.0F;
class="kw">private boolean normalizeDistances;
class="kw">public GroupSteeringAccumulator() {
}
class="kw">public void begin(double var1, double var3, double var5, double var7, double var9, double var11) {
this.x = var1;
this.y = var3;
this.z = var5;
this.xViewDirection = var7;
this.yViewDirection = var9;
this.zViewDirection = var11;
this.sumOfDistances.zero();
this.sumOfPositions.zero();
this.sumOfVelocities.zero();
this.count = 0;
}
class="kw">public void begin(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
HeadRotation var3 = var2.getComponent(var1, HeadRotation.getComponentType());
assert var3 != null;
Rotation3f var4 = var3.getRotation();
NPCPhysicsMath.getViewDirection(var4, this.temp);
this.temp.normalize();
TransformComponent var5 = var2.getComponent(var1, TRANSFORM_COMPONENT_TYPE);
assert var5 != null;
Vector3d var6 = var5.getPosition();
this.begin(var6.x(), var6.y(), var6.z(), this.temp.x, this.temp.y, this.temp.z);
}
class="kw">public void processEntity(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
Velocity var15 = var2.getComponent(var1, Velocity.getComponentType());
assert var15 != null;
Vector3d var16 = var15.getVelocity();
TransformComponent var17 = var2.getComponent(var1, TRANSFORM_COMPONENT_TYPE);
assert var17 != null;
Vector3d var18 = var17.getPosition();
double var9 = var18.x();
double var11 = var18.y();
double var13 = var18.z();
double var3 = var9 - this.x;
double var5 = var11 - this.y;
double var7 = var13 - this.z;
if (NPCPhysicsMath.dotProduct(var3, var5, var7, this.componentSelector) < this.maxRangeSquared
&& NPCPhysicsMath.isInViewCone(this.xViewDirection, this.yViewDirection, this.zViewDirection, this.collisionViewHalfAngleCosine, var3, var5, var7)) {
this.sumOfDistances.add(var3, var5, var7);
this.sumOfPositions.add(var9, var11, var13);
this.sumOfVelocities.add(var16);
this.count++;
}
}
class="kw">public void processEntity(@Nonnull Ref<EntityStore> var1, double var2, double var4, double var6, @Nonnull ComponentAccessor<EntityStore> var8) {
TransformComponent var9 = var8.getComponent(var1, TRANSFORM_COMPONENT_TYPE);
assert var9 != null;
Vector3d var10 = var9.getPosition();
Velocity var11 = var8.getComponent(var1, Velocity.getComponentType());
assert var11 != null;
Vector3d var12 = var11.getVelocity();
double var13 = var10.x() - this.x;
double var15 = var10.y() - this.y;
double var17 = var10.z() - this.z;
double var19 = NPCPhysicsMath.dotProduct(var13, var15, var17, this.componentSelector);
if (var19 < this.maxRangeSquared
&& NPCPhysicsMath.isInViewCone(this.xViewDirection, this.yViewDirection, this.zViewDirection, this.collisionViewHalfAngleCosine, var13, var15, var17)) {
double var21;
if (!this.normalizeDistances) {
var21 = Math.sqrt(var19);
} else {
if (var19 < 1.0E-12) {
do {
var13 = RandomExtra.randomRange(-1.0, 1.0);
var15 = RandomExtra.randomRange(-1.0, 1.0);
var17 = RandomExtra.randomRange(-1.0, 1.0);
var19 = NPCPhysicsMath.dotProduct(var13, var15, var17);
} while (var19 < 1.0E-12);
double var23 = 1.0E-6 / Math.sqrt(var19);
var13 *= var23;
var15 *= var23;
var17 *= var23;
var19 = 1.0E-12;
}
var21 = Math.sqrt(var19);
double var30 = 1.0 / var21;
var13 *= var30;
var15 *= var30;
var17 *= var30;
}
var19 = 1.0 - var21 / this.maxDistance;
double var31 = Math.pow(var19, var2);
this.sumOfDistances.add(var13 * var31, var15 * var31, var17 * var31);
var31 = Math.pow(var19, var4);
this.sumOfPositions.fma(var31, var10);
var31 = Math.pow(var19, var6);
this.sumOfVelocities.fma(var31, var12);
this.count++;
}
}
class="kw">public void end() {
if (this.count > 0) {
if (this.normalizeDistances) {
if (this.sumOfDistances.lengthSquared() >= 1.0) {
this.sumOfDistances.normalize();
}
} else {
double var1 = 1.0 / this.count;
this.sumOfDistances.mul(var1).mul(this.componentSelector);
this.sumOfPositions.mul(var1).mul(this.componentSelector);
this.sumOfVelocities.mul(var1).mul(this.componentSelector);
}
}
}
class="kw">public void setComponentSelector(Vector3d var1) {
this.componentSelector.set(var1);
}
class="kw">public void setMaxRange(double var1) {
this.maxRangeSquared = var1 * var1;
this.maxDistance = var1;
}
class="kw">public void setNormalizeDistances(boolean var1) {
this.normalizeDistances = var1;
}
class="kw">public void setViewConeHalfAngleCosine(float var1) {
this.collisionViewHalfAngleCosine = var1;
}
@Nonnull
class="kw">public Vector3d getSumOfVelocities() {
class="kw">return this.sumOfVelocities;
}
@Nonnull
class="kw">public Vector3d getSumOfDistances() {
class="kw">return this.sumOfDistances;
}
@Nonnull
class="kw">public Vector3d getSumOfPositions() {
class="kw">return this.sumOfPositions;
}
class="kw">public int getCount() {
class="kw">return this.count;
}
}